Reputation: 2249
I'm trying to setup some custom monitoring for postgres and one of the metrics I want to see is the index usage from pg_stat_user_indexes
. I have multiple databases, each of them have indexes and I want a single metrics
role that has access to all of them.
The problem is that when I select * from pg_stat_user_indexes
using the metrics
role I see no results. But if I select with the individual database role I see the stats just fine.
The metrics
role is a superuser with Bypass RLS. I tried looking at pg_stat_all_indexes
but I can see only pg_*
stuff.
Upvotes: 0
Views: 1213
Reputation: 51609
https://www.postgresql.org/docs/current/static/monitoring-stats.html#pg-stat-all-indexes-view
The pg_stat_all_indexes view will contain one row for each index in the current database, showing statistics about accesses to that specific index. The pg_stat_user_indexes and pg_stat_sys_indexes views contain the same information, but filtered to only show user and system indexes respectively.
emphasis mine
Upvotes: 1
Reputation: 2249
Seems like you need to be connected to the specific database you want to monitor (not to postgres db) in order to see those stats.
Bizarre.. would have at least expected to see them all in pg_stat_all_indexes
- it should have been named pg_stat_all_indexes_for_current_database_plus_pg_catalog
- I know.. but pg_stat_all_indexes
is not all indexes at all..
Upvotes: 0