PostgreSQL DBA(149) - PG 12(Add SETTINGS option to EXPLAIN)

PostgreSQL 12为explain命令提供了settings选项,可查看影响执行计划的设置修改.
影响PG执行计划的参数包括:

enable_seqscan, enable_indexscan enable_index only scan, enable_bitmapscan;
temp_buffers, work_mem;
max_parallel_workers_per_gather, max_parallel_workers, enable_gathermerge;
effective_cache_size;
min_parallel_table_scan_size, min_parallel_index_scan_size;
enable_parallel_append, enable_parallel_hash, enable_partition_pruning;
enable_nestloop, enable_mergejoin, enable_hashjoin;
enable_tidscan;
enable_sort;
enable_hashagg;
enable_material;
enable_partitionwise_join;
enable_partitionwise_aggregate;
geqo;
optimize_bounded_sort;
parallel_leader_participation;
jit;
from_collapse_limit;
join_collapse_limit;
geqo_threshold;
geqo_effort;
geqo_pool_size;
geqo_generations;
effective_io_concurrency;

[local:/data/run/pg12]:5120 pg12@testdb=# explain (format text,settings on) select * from t_mvcc;
                        QUERY PLAN                        
----------------------------------------------------------
 Seq Scan on t_mvcc  (cost=0.00..35.50 rows=2550 width=4)
(1 row)
[local:/data/run/pg12]:5120 pg12@testdb=# set enable_seqscan=off;
SET
[local:/data/run/pg12]:5120 pg12@testdb=# explain (format text,settings on) select * from t_mvcc;
                                 QUERY PLAN                                  
-----------------------------------------------------------------------------
 Seq Scan on t_mvcc  (cost=10000000000.00..10000000035.50 rows=2550 width=4)
 Settings: enable_seqscan = 'off'
(2 rows)
[local:/data/run/pg12]:5120 pg12@testdb=#

值得一提的是,设置enable_XXXscan=off并不是真的禁用而是把该路径的成本设置为一个很大的值(10000000000)。

参考资料
Waiting for PostgreSQL 12 – Add SETTINGS option to EXPLAIN, to print modified settings
PostgreSQL 12 EXPLAIN SETTINGS
Add SETTINGS option to EXPLAIN, to print modified settings.

请使用浏览器的分享功能分享到微信等