postgres statistics - ghdrako/doc_snipets GitHub Wiki

The statistic collector collects various statistics about tables, indexes, and database activity, providing valuable insights into data distribution and access patterns. This information is then used by the statistic analyzer, which analyzes the collected statistics and updates them accordingly. By enabling these components and regularly analyzing the statistics, database administrators can ensure that the query planner makes accurate decisions based on the actual data distribution, resulting in more efficient query execution and improved overall performance of the PostgreSQL database.

  • Enabling the statistic collect or postgresql.conf
track_counts = on
  • Querying statistics
SELECT * FROM pg_stat_all_tables WHERE relname = 'testings';
  • Analyzing statistics
ANALYZE <Table_Name>;
VACUUM ANALYZE <Table_Name>; -- command to perform both vacuuming and analysis simultaneously.
⚠️ **GitHub.com Fallback** ⚠️