diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-03-24 14:06:10 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-03-24 14:06:10 -0300 |
commit | 7b504eb282ca2f5104b5c00b4f05a3ef6bb1385b (patch) | |
tree | 4b12f53c5bd25a03f1016f1daa0809606b47df3a /doc/src/sgml/ref/alter_statistics.sgml | |
parent | f120b614e070aed39586d1443193738a149a90d4 (diff) | |
download | postgresql-7b504eb282ca2f5104b5c00b4f05a3ef6bb1385b.tar.gz postgresql-7b504eb282ca2f5104b5c00b4f05a3ef6bb1385b.zip |
Implement multivariate n-distinct coefficients
Add support for explicitly declared statistic objects (CREATE
STATISTICS), allowing collection of statistics on more complex
combinations that individual table columns. Companion commands DROP
STATISTICS and ALTER STATISTICS ... OWNER TO / SET SCHEMA / RENAME are
added too. All this DDL has been designed so that more statistic types
can be added later on, such as multivariate most-common-values and
multivariate histograms between columns of a single table, leaving room
for permitting columns on multiple tables, too, as well as expressions.
This commit only adds support for collection of n-distinct coefficient
on user-specified sets of columns in a single table. This is useful to
estimate number of distinct groups in GROUP BY and DISTINCT clauses;
estimation errors there can cause over-allocation of memory in hashed
aggregates, for instance, so it's a worthwhile problem to solve. A new
special pseudo-type pg_ndistinct is used.
(num-distinct estimation was deemed sufficiently useful by itself that
this is worthwhile even if no further statistic types are added
immediately; so much so that another version of essentially the same
functionality was submitted by Kyotaro Horiguchi:
https://postgr.es/m/20150828.173334.114731693.horiguchi.kyotaro@lab.ntt.co.jp
though this commit does not use that code.)
Author: Tomas Vondra. Some code rework by Álvaro.
Reviewed-by: Dean Rasheed, David Rowley, Kyotaro Horiguchi, Jeff Janes,
Ideriha Takeshi
Discussion: https://postgr.es/m/543AFA15.4080608@fuzzy.cz
https://postgr.es/m/20170320190220.ixlaueanxegqd5gr@alvherre.pgsql
Diffstat (limited to 'doc/src/sgml/ref/alter_statistics.sgml')
-rw-r--r-- | doc/src/sgml/ref/alter_statistics.sgml | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/doc/src/sgml/ref/alter_statistics.sgml b/doc/src/sgml/ref/alter_statistics.sgml new file mode 100644 index 00000000000..3e4d28614a2 --- /dev/null +++ b/doc/src/sgml/ref/alter_statistics.sgml @@ -0,0 +1,115 @@ +<!-- +doc/src/sgml/ref/alter_statistics.sgml +PostgreSQL documentation +--> + +<refentry id="SQL-ALTERSTATISTICS"> + <indexterm zone="sql-alterstatistics"> + <primary>ALTER STATISTICS</primary> + </indexterm> + + <refmeta> + <refentrytitle>ALTER STATISTICS</refentrytitle> + <manvolnum>7</manvolnum> + <refmiscinfo>SQL - Language Statements</refmiscinfo> + </refmeta> + + <refnamediv> + <refname>ALTER STATISTICS</refname> + <refpurpose> + change the definition of a extended statistics + </refpurpose> + </refnamediv> + + <refsynopsisdiv> +<synopsis> +ALTER STATISTICS <replaceable class="parameter">name</replaceable> OWNER TO { <replaceable class="PARAMETER">new_owner</replaceable> | CURRENT_USER | SESSION_USER } +ALTER STATISTICS <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable> +ALTER STATISTICS <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable> +</synopsis> + </refsynopsisdiv> + + <refsect1> + <title>Description</title> + + <para> + <command>ALTER STATISTICS</command> changes the parameters of an existing + extended statistics. Any parameters not specifically set in the + <command>ALTER STATISTICS</command> command retain their prior settings. + </para> + + <para> + You must own the statistics to use <command>ALTER STATISTICS</>. + To change a statistics' schema, you must also have <literal>CREATE</> + privilege on the new schema. + To alter the owner, you must also be a direct or indirect member of the new + owning role, and that role must have <literal>CREATE</literal> privilege on + the statistics' schema. (These restrictions enforce that altering the owner + doesn't do anything you couldn't do by dropping and recreating the statistics. + However, a superuser can alter ownership of any statistics anyway.) + </para> + </refsect1> + + <refsect1> + <title>Parameters</title> + + <para> + <variablelist> + <varlistentry> + <term><replaceable class="parameter">name</replaceable></term> + <listitem> + <para> + The name (optionally schema-qualified) of the statistics to be altered. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><replaceable class="PARAMETER">new_owner</replaceable></term> + <listitem> + <para> + The user name of the new owner of the statistics. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><replaceable class="parameter">new_name</replaceable></term> + <listitem> + <para> + The new name for the statistics. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><replaceable class="parameter">new_schema</replaceable></term> + <listitem> + <para> + The new schema for the statistics. + </para> + </listitem> + </varlistentry> + + </variablelist> + </para> + </refsect1> + + <refsect1> + <title>Compatibility</title> + + <para> + There's no <command>ALTER STATISTICS</command> command in the SQL standard. + </para> + </refsect1> + + <refsect1> + <title>See Also</title> + + <simplelist type="inline"> + <member><xref linkend="sql-createstatistics"></member> + <member><xref linkend="sql-dropstatistics"></member> + </simplelist> + </refsect1> + +</refentry> |