From ee6263b1338a219c25892e8321688701dd608b8c Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Thu, 6 Jun 2019 16:08:49 +0200 Subject: [PATCH 2/3] update docs after splitting stats --- doc/src/sgml/catalogs.sgml | 62 ++++++++++++++++++++++++++++++++----- doc/src/sgml/func.sgml | 4 +-- doc/src/sgml/perform.sgml | 12 ++++--- doc/src/sgml/planstats.sgml | 2 +- 4 files changed, 66 insertions(+), 14 deletions(-) diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 36193d1491..a17e22540c 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -297,7 +297,12 @@ pg_statistic_ext - extended planner statistics + extended planner statistics (definition) + + + + pg_statistic_ext_data + extended planner statistics (built statistics) @@ -6581,6 +6586,55 @@ SCRAM-SHA-256$<iteration count>:&l + + + + + + The stxkind field is filled at creation of the + statistics object, indicating which statistic type(s) are desired. The + statistics (once computed by ANALYZE) are stored in + pg_statistic_ext_data + catalog. + + + + + <structname>pg_statistic_ext_data</structname> + + + pg_statistic_ext + + + + The catalog pg_statistic_ext + holds extended planner statistics. + Each row in this catalog corresponds to a statistics object + created with . + + + + <structname>pg_statistic_ext_data</structname> Columns + + + + + Name + Type + References + Description + + + + + + + stxoid + oid + pg_statistic_ext.oid + Extended statistic containing the definition for this data. + + stxndistinct pg_ndistinct @@ -6614,12 +6668,6 @@ SCRAM-SHA-256$<iteration count>:&l
- - The stxkind field is filled at creation of the - statistics object, indicating which statistic type(s) are desired. - The fields after it are initially NULL and are filled only when the - corresponding statistic has been computed by ANALYZE. -
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 8debb8cbbc..6bdbba74dd 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -22385,12 +22385,12 @@ CREATE EVENT TRIGGER test_table_rewrite_oid The pg_mcv_list_items function can be used like this: -SELECT m.* FROM pg_statistic_ext, +SELECT m.* FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid), pg_mcv_list_items(stxmcv) m WHERE stxname = 'stts'; Values of the pg_mcv_list can be obtained only from the - pg_statistic_ext.stxmcv column. + pg_statistic_ext_data.stxmcv column. diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml index a84be85159..087b0e555f 100644 --- a/doc/src/sgml/perform.sgml +++ b/doc/src/sgml/perform.sgml @@ -1076,6 +1076,10 @@ WHERE tablename = 'road'; pg_statistic_ext + + pg_statistic_ext_data + + It is common to see slow queries running bad execution plans because multiple columns used in the query clauses are correlated. @@ -1104,7 +1108,7 @@ WHERE tablename = 'road'; interest in the statistics. Actual data collection is performed by ANALYZE (either a manual command, or background auto-analyze). The collected values can be examined in the - pg_statistic_ext + pg_statistic_ext_data catalog. @@ -1173,7 +1177,7 @@ CREATE STATISTICS stts (dependencies) ON zip, city FROM zipcodes; ANALYZE zipcodes; SELECT stxname, stxkeys, stxdependencies - FROM pg_statistic_ext + FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid) WHERE stxname = 'stts'; stxname | stxkeys | stxdependencies ---------+---------+------------------------------------------ @@ -1263,7 +1267,7 @@ CREATE STATISTICS stts2 (ndistinct) ON zip, state, city FROM zipcodes; ANALYZE zipcodes; SELECT stxkeys AS k, stxndistinct AS nd - FROM pg_statistic_ext + FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid) WHERE stxname = 'stts2'; -[ RECORD 1 ]-------------------------------------------------------- k | 1 2 5 @@ -1317,7 +1321,7 @@ CREATE STATISTICS stts3 (mcv) ON state, city FROM zipcodes; ANALYZE zipcodes; -SELECT m.* FROM pg_statistic_ext, +SELECT m.* FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid), pg_mcv_list_items(stxmcv) m WHERE stxname = 'stts3'; index | values | nulls | frequency | base_frequency diff --git a/doc/src/sgml/planstats.sgml b/doc/src/sgml/planstats.sgml index 4b1d3f4952..f85f91dd13 100644 --- a/doc/src/sgml/planstats.sgml +++ b/doc/src/sgml/planstats.sgml @@ -635,7 +635,7 @@ EXPLAIN (ANALYZE, TIMING OFF) SELECT * FROM t WHERE a = 1 AND b = 1; pg_mcv_list_items set-returning function. -SELECT m.* FROM pg_statistic_ext, +SELECT m.* FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid), pg_mcv_list_items(stxmcv) m WHERE stxname = 'stts2'; index | values | nulls | frequency | base_frequency -------+----------+-------+-----------+---------------- -- 2.20.1