Interview Questions PostgreSQL Interview Questions

[Interview Question] – How do I know if the statistics of a table are up to date in PostgreSQL?

Answer:

Check the System Catalog : pg_stat_all_tables.

You can see last_analyze column from pg_stat_all_tables to see when the table was last analyzed.

Example:

psql # SELECT schemaname, relname, last_analyze FROM pg_stat_all_tables WHERE relname = 'emp';

Whenever a table’s statistics are out-of-date running VACUUM recommended.

If the estimated rowcount on the table [schema].[table] deviates significantly from the actual rowcount. You should run VACUUM ANALYZE on this table.


Review
4
Comments Rating 0 (0 reviews)

About the author

BestTechReads

Add Comment

Click here to post a comment

Sending

Categories

Categories