原 GreenPlum中如何根据统计信息计算值的分步情况
Tags: 原创PGGreenPlumPostgreSQL优化统计信息
前言
若有一张特大表,则做group by或where过滤是非常慢的,这个时候可以通过统计信息来快速获取一些数据。
更新统计信息
1 2 | ANALYZE pg_class; vacuum (verbose,ANALYZE) pg_class; |
查询统计信息
1 2 3 | select a.n_distinct,a.most_common_vals,most_common_freqs from pg_stats a where a.tablename='pg_class' and a.attname='relhasindex'; select count(*) from pg_class a where a.relhasindex='t'; select count(*) from pg_class; |