How to discover what a Postgresql table's usage is?

痴心易碎 提交于 2020-01-16 00:41:33

问题


Our team is working on a Postgresql database with lots of tables and views, without any referential constraints. The project is undocumented and there appears to be a great number of unused/temporary/duplicate tables/views dirtying the schema.

We need to discover what database objects have real value and are actually used and accessed. My inital thoughts were to query the Catalog/'data-dictionary'.

Is it possible to query the Postgresql Catalog to find an object's last query time.

Any thoughts, alternative approaches and or tools ideas?


回答1:


Check the Statistics Collector




回答2:


Not sure about the last query time but you can adjust your postgresql.conf to log all SQL:

log_min_duration_statement = 0

That will at least give you an idea of current activity.




回答3:


Reset the statistics, pg_stat_reset(), and then check the pg catalog tables like pg_stat_user_tables and such to see where activity looks like its showing up.



来源:https://stackoverflow.com/questions/3868423/how-to-discover-what-a-postgresql-tables-usage-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!