We want to check if we have unused indexes in our postgres 15.5 RDS instances.
Currently, we did "CREATE EXTENSION IF NOT EXISTS pg_stat_statements"
Which enables pg_stat_satements, but what we need is: "pg_stat_user_indexes"
The question is, how do we enable it?
The only info we can find is that "track_activities" config parameter should be set to true, but we dont know if this will enable all of the hundres of pg_stat tracking, or if there is more to do to specifically enable the collection of pg_stat_user_indexes.
Also, we dont know how to change parameters exactly. all 30 of our prod DBs have the same production parameter group. If we edit this parameter group, it will affect all 30DBs, and we only want to enable this on one. Is there some workaround for this? E.g. duplicate the prod parameter group (if this is possible via the web ui), and reassign the new temporary group (without a reboot).
Also, we certainly cant reboot any production servers, so we need a way to enable/disable tracking of pg_stat_user_indexes without reboot.
Any ideas?
1 Answer 1
Found a set of steps which dont require reboot:
- copied the parameter group used by all dbs to a temp copy.
- set "track_activities" dynamic value to true (1) on the temp copy.
- modified one DB and assigned it to the new temp parameter group.
- waited till it said modification complete.
Now I can do 'select * from pg_stat_user_indexes;'
track_activities
ison
by default (indispensable for autovacuum), andpg_stat_user_indexes
always exists, so unless Amazon messed that up somehow, there is nothing to do.