PostgreSQL Index Usage Analysis

前端 未结 9 1623
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 17:43

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

相关标签:
9条回答
  • 2021-01-29 18:10

    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.

    0 讨论(0)
  • 2021-01-29 18:10

    Another new and interesting tool for analyzing PostgreSQL is PgHero. It is more focused on tuning the database and makes numerous analysis and suggestions.

    0 讨论(0)
  • 2021-01-29 18:16

    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

    0 讨论(0)
提交回复
热议问题