pg_store_plans
The PostgreSQL extension pg_store_plans is a contrib module that provides a way to store execution plans generated by the query planner.
Last updated
export PATH=<<POSTGRESQL_DIRECTORY>>/bin:$PATHdnf install postgresql<<VERSION>>-develpg_configtar xvzf pg_store_plans-2.0.tar.gz
cd pg_store_plans-2.0make
sudo make installtar xvzf <<VERSION>>.tar.gz
cd pg_store_plansmake USE_PGXS=1
sudo make install USE_PGXS=1
pg_store_plans.max=1000
pg_store_plans.track=all
pg_store_plans.plan_format=text
#
# Consider setting this parameter to a value greater
# than 0 if you don't want to collect all plans
pg_store_plans.min_duration=0
pg_store_plans.log_analyze = false
pg_store_plans.log_timing = false
pg_store_plans.log_buffers=false
pg_store_plans.log_triggers=false
pg_store_plans.log_verbose=false
pg_store_plans.save=false
# Exclude simple INSERT statements (INSERT ... VALUES); INSERT ... SELECT remains collected
pg_store_plans.exclude_simple_inserts=on
# Anonymize
pg_store_plans.anonymize=onCREATE EXTENSION pg_store_plans; SELECT current_database(), extname, extversion from pg_extension where extname ='pg_store_plans';
current_database | extname | extversion
------------------+----------------+------------
postgres | pg_store_plans | 2.0.1
(1 row)
\dx pg_store_plans
List of installed extensions
Name | Version | Schema | Description
----------------+---------+--------+-----------------------------------------------------------------------------
pg_store_plans | 2.0.1 | public | Datasentinel SQL execution plan tracking extension (fork of pg_store_plans)
(1 row)SELECT name, setting from pg_settings where name like 'pg_store_plans%';
name | setting
---------------------------------------+---------
pg_store_plans.anonymize | on
pg_store_plans.exclude_simple_inserts | off
pg_store_plans.log_analyze | off
pg_store_plans.log_buffers | off
pg_store_plans.log_timing | off
pg_store_plans.log_triggers | off
pg_store_plans.log_verbose | off
pg_store_plans.max | 1000
pg_store_plans.max_plan_length | 5000
pg_store_plans.min_duration | 0
pg_store_plans.plan_format | text
pg_store_plans.plan_storage | file
pg_store_plans.save | on
pg_store_plans.track | allSELECT dbid, count(*) from pg_store_plans group by dbid;