SELECT schemaname, relname, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze FROM pg_stat_user_tables WHERE relname = 'documents'; schemaname | relname | last_vacuum | last_autovacuum | last_analyze | last_autoanalyze ----------------+----------+-------------+-------------------------------+-------------------------------+------------------------------- scott | documents| | 2025-06-25 02:05:20.692869+02 | 2025-07-12 22:04:05.119051+02 | 2025-06-17 08:41:12.567351+02 (1 row)Explanation of columns:
What does ANALYZE do in PostgreSQL?
ANALYZE collects statistics about the contents of a table (or all tables), such as:
Syntax to run ANALYZE
Analyze the entire database (all tables in all schemas):
ANALYZE;Analyze a specific table:
ANALYZE my_table;Analyze specific columns only:
ANALYZE my_table (column1, column2);