点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!Postgres数据库中查看sql的执行计划等,对sql的提优具有重要意义。
1. 查看执行计划
3)EXPLAIN ANALYZEPERFORMANCE命令查看执行过程的瓶颈算子,然后进行针对性优化explain (analyze on, costs off) SQL语句。Part One
where relname = 'tableName';Part Two
-- 高频值个数,简称MCV,由default_statistics_target(默认100)决定记录多少个 -- 等频直方图,剔除MCV后,每个区间范围中的元素在总元组中的占比一样 where tablename = 'tableName' and attname = 'columnname';Part three
where tablename = 'tableName';Part IV
where stxname = #stxname#Part Five
-- 查看统计信息更新时间 ,视图pg_stat_all_tables last_analyze --最近一次统计信息更新时间 last_autoanalyze --最近一次自动统计信息更新时间select schemaname,relname,last_analyze,
last_autoanalyze from pg_stat_all_tables where schemaname='xxx' and relname = 'test';
复制