Is there a tool or method to analyze Postgres, and determine what missing indexes should be created, and which unused indexes should be removed? I have a little experience doing
On the determine missing indexes approach....Nope. But there's some plans to make this easier in future release, like pseudo-indexes and machine readable EXPLAIN.
Currently, you'll need to EXPLAIN ANALYZE
poor performing queries and then manually determine the best route. Some log analyzers like pgFouine can help determine the queries.
As far as an unused index, you can use something like the following to help identify them:
select * from pg_stat_all_indexes where schemaname <> 'pg_catalog';
This will help identify tuples read, scanned, fetched.
Another new and interesting tool for analyzing PostgreSQL is PgHero. It is more focused on tuning the database and makes numerous analysis and suggestions.
It can be found by using following query in postgres console
use db_name
select * from pg_stat_user_indexes;
select * from pg_statio_user_indexes;
For More Details https://www.postgresql.org/docs/current/monitoring-stats.html