From 76a47c0e7423891d4b4f0977312f46fec6c5c416 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 22 Jan 2010 16:40:19 +0000 Subject: Replace ALTER TABLE ... SET STATISTICS DISTINCT with a more general mechanism. Attributes can now have options, just as relations and tablespaces do, and the reloptions code is used to parse, validate, and store them. For simplicity and because these options are not performance critical, we store them in a separate cache rather than the main relcache. Thanks to Alex Hunsaker for the review. --- doc/src/sgml/catalogs.sgml | 24 ++++++++++-------------- doc/src/sgml/ref/alter_table.sgml | 24 ++++++++++++++++-------- doc/src/sgml/ref/analyze.sgml | 4 ++-- 3 files changed, 28 insertions(+), 24 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index f917652a085..74b2c4b4e16 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,4 +1,4 @@ - + @@ -901,19 +901,6 @@ - - attdistinct - float4 - - - attdistinct, if nonzero, is a user-specified - number-of-distinct-values figure to be used instead of estimating the - number of distinct values during ANALYZE. Nonzero values - have the same meanings as for - pg_statistic.stadistinct - - - attlen int2 @@ -1061,6 +1048,15 @@ + + attoptions + text[] + + + Attribute-level options, as keyword=value strings + + + diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 354fa20edf7..7f4cb37e6e3 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1,5 +1,5 @@ @@ -39,7 +39,8 @@ ALTER TABLE name ALTER [ COLUMN ] column DROP DEFAULT ALTER [ COLUMN ] column { SET | DROP } NOT NULL ALTER [ COLUMN ] column SET STATISTICS integer - ALTER [ COLUMN ] column SET STATISTICS DISTINCT number + ALTER [ COLUMN ] column SET ( attribute_option = value [, ... ] ) + ALTER [ COLUMN ] column RESET ( attribute_option [, ... ] ) ALTER [ COLUMN ] column SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } ADD table_constraint DROP CONSTRAINT [ IF EXISTS ] constraint_name [ RESTRICT | CASCADE ] @@ -158,14 +159,21 @@ ALTER TABLE name - SET STATISTICS DISTINCT + SET ( attribute_option = value [, ... ] ) + RESET ( attribute_option [, ... ] ) - This form overrides the number-of-distinct-values estimate made by - subsequent - operations. When set to a positive value, ANALYZE will - assume that the column contains exactly the specified number of distinct - nonnull values. When set to a negative value, which must be greater + This form sets or resets attribute-level options. Currently, the only + define attribute-level options are n_distinct and + n_distinct_inherited, which override the + number-of-distinct-values estimate made by subsequent + + operations. n_distinct affects the statistics for the table + itself, while n_distinct_inherited affects the statistics + gathered for the table and its inheritance children. When set to a + positive value, ANALYZE will assume that the column contains + exactly the specified number of distinct nonnull values. When set to a + negative value, which must be greater than or equal to -1, ANALYZE will assume that the number of distinct nonnull values in the column is linear in the size of the table; the exact count is to be computed by multiplying the estimated diff --git a/doc/src/sgml/ref/analyze.sgml b/doc/src/sgml/ref/analyze.sgml index cb9f20f3f56..7564ce1448e 100644 --- a/doc/src/sgml/ref/analyze.sgml +++ b/doc/src/sgml/ref/analyze.sgml @@ -1,5 +1,5 @@ @@ -173,7 +173,7 @@ ANALYZE [ VERBOSE ] [ table [ ( ALTER TABLE ... ALTER COLUMN ... SET STATISTICS DISTINCT + ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...) (see ). -- cgit v1.2.3