mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Collect and use multi-column dependency stats
Follow on patch in the multi-variate statistics patch series.
CREATE STATISTICS s1 WITH (dependencies) ON (a, b) FROM t;
ANALYZE;
will collect dependency stats on (a, b) and then use the measured
dependency in subsequent query planning.
Commit 7b504eb282
added
CREATE STATISTICS with n-distinct coefficients. These are now
specified using the mutually exclusive option WITH (ndistinct).
Author: Tomas Vondra, David Rowley
Reviewed-by: Kyotaro HORIGUCHI, Álvaro Herrera, Dean Rasheed, Robert Haas
and many other comments and contributions
Discussion: https://postgr.es/m/56f40b20-c464-fad2-ff39-06b668fac47c@2ndquadrant.com
This commit is contained in:
@@ -21,8 +21,9 @@ PostgreSQL documentation
|
||||
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
CREATE STATISTICS [ IF NOT EXISTS ] <replaceable class="PARAMETER">statistics_name</replaceable> ON (
|
||||
<replaceable class="PARAMETER">column_name</replaceable>, <replaceable class="PARAMETER">column_name</replaceable> [, ...])
|
||||
CREATE STATISTICS [ IF NOT EXISTS ] <replaceable class="PARAMETER">statistics_name</replaceable>
|
||||
WITH ( <replaceable class="PARAMETER">option</replaceable> [= <replaceable class="PARAMETER">value</replaceable>] [, ... ] )
|
||||
ON ( <replaceable class="PARAMETER">column_name</replaceable>, <replaceable class="PARAMETER">column_name</replaceable> [, ...])
|
||||
FROM <replaceable class="PARAMETER">table_name</replaceable>
|
||||
</synopsis>
|
||||
|
||||
@@ -94,6 +95,41 @@ CREATE STATISTICS [ IF NOT EXISTS ] <replaceable class="PARAMETER">statistics_na
|
||||
|
||||
</variablelist>
|
||||
|
||||
<refsect2 id="SQL-CREATESTATISTICS-parameters">
|
||||
<title id="SQL-CREATESTATISTICS-parameters-title">Parameters</title>
|
||||
|
||||
<indexterm zone="sql-createstatistics-parameters">
|
||||
<primary>statistics parameters</primary>
|
||||
</indexterm>
|
||||
|
||||
<para>
|
||||
The <literal>WITH</> clause can specify <firstterm>options</>
|
||||
for the statistics. Available options are listed below.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>dependencies</> (<type>boolean</>)</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Enables functional dependencies for the statistics.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>ndistinct</> (<type>boolean</>)</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Enables ndistinct coefficients for the statistics.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
@@ -122,7 +158,7 @@ CREATE TABLE t1 (
|
||||
INSERT INTO t1 SELECT i/100, i/500
|
||||
FROM generate_series(1,1000000) s(i);
|
||||
|
||||
CREATE STATISTICS s1 ON (a, b) FROM t1;
|
||||
CREATE STATISTICS s1 WITH (dependencies) ON (a, b) FROM t1;
|
||||
|
||||
ANALYZE t1;
|
||||
|
||||
|
Reference in New Issue
Block a user