diff options
author | Tomas Vondra | 2022-01-16 12:37:56 +0000 |
---|---|---|
committer | Tomas Vondra | 2022-01-16 12:38:01 +0000 |
commit | 269b532aef55a579ae02a3e8e8df14101570dfd9 (patch) | |
tree | 9a3b874d97938f14617e0f9f62c7f548ea790696 /doc/src | |
parent | e701bdd2f042829402d96589cb16ae218967af73 (diff) |
Add stxdinherit flag to pg_statistic_ext_data
Add pg_statistic_ext_data.stxdinherit flag, so that for each extended
statistics definition we can store two versions of data - one for the
relation alone, one for the whole inheritance tree. This is analogous to
pg_statistic.stainherit, but we failed to include such flag in catalogs
for extended statistics, and we had to work around it (see commits
859b3003de, 36c4bc6e72 and 20b9fa308e).
This changes the relationship between the two catalogs storing extended
statistics objects (pg_statistic_ext and pg_statistic_ext_data). Until
now, there was a simple 1:1 mapping - for each definition there was one
pg_statistic_ext_data row, and this row was inserted while creating the
statistics (and then updated during ANALYZE). With the stxdinherit flag,
we don't know how many rows there will be (child relations may be added
after the statistics object is defined), so there may be up to two rows.
We could make CREATE STATISTICS to always create both rows, but that
seems wasteful - without partitioning we only need stxdinherit=false
rows, and declaratively partitioned tables need only stxdinherit=true.
So we no longer initialize pg_statistic_ext_data in CREATE STATISTICS,
and instead make that a responsibility of ANALYZE. Which is what we do
for regular statistics too.
Patch by me, with extensive improvements and fixes by Justin Pryzby.
Author: Tomas Vondra, Justin Pryzby
Reviewed-by: Tomas Vondra, Justin Pryzby
Discussion: https://postgr.es/m/20210923212624.GI831%40telsasoft.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 03e2537b07d..2aeb2ef346e 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -7522,6 +7522,19 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l </para> <para> + Normally there is one entry, with <structfield>stxdinherit</structfield> = + <literal>false</literal>, for each statistics object that has been analyzed. + If the table has inheritance children, a second entry with + <structfield>stxdinherit</structfield> = <literal>true</literal> is also created. + This row represents the statistics object over the inheritance tree, i.e., + statistics for the data you'd see with + <literal>SELECT * FROM <replaceable>table</replaceable>*</literal>, + whereas the <structfield>stxdinherit</structfield> = <literal>false</literal> row + represents the results of + <literal>SELECT * FROM ONLY <replaceable>table</replaceable></literal>. + </para> + + <para> Like <link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link>, <structname>pg_statistic_ext_data</structname> should not be readable by the public, since the contents might be considered sensitive. @@ -7562,6 +7575,16 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l <row> <entry role="catalog_table_entry"><para role="column_definition"> + <structfield>stxdinherit</structfield> <type>bool</type> + </para> + <para> + If true, the stats include inheritance child columns, not just the + values in the specified relation + </para></entry> + </row> + + <row> + <entry role="catalog_table_entry"><para role="column_definition"> <structfield>stxdndistinct</structfield> <type>pg_ndistinct</type> </para> <para> |