How to tell when a Postgres table was clustered and what indexes were used

假如想象 提交于 2019-12-05 14:28:00

To tell which index was last used to cluster the table, use the pg_index system catalog.

Query the table for all indexes that belong to your table and see which one has indisclustered set. A table can only be clustered by a single index at a time.

There is no way to find out when the table was last clustered, but that's not very interesting anyway. What you want to know is how good the clustering still is.

To find that, query the pg_stats line for the column on which you clustered. If correlation is close to 1, you are still good. The smaller the value gets, the more clustering is indicated.

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