diff options
author | Richard Guo <rguo@postgresql.org> | 2024-11-26 09:25:18 +0900 |
---|---|---|
committer | Richard Guo <rguo@postgresql.org> | 2024-11-26 09:25:18 +0900 |
commit | a8ccf4e93a7eeaae66007bbf78cf9183ceb1b371 (patch) | |
tree | 8ef9b2d3f02d8f51de10ce95531de962245a451d /doc/src | |
parent | 5b8728cd7f9d3d93b6ff9b48887084fdf0a46e4f (diff) | |
download | postgresql-a8ccf4e93a7eeaae66007bbf78cf9183ceb1b371.tar.gz postgresql-a8ccf4e93a7eeaae66007bbf78cf9183ceb1b371.zip |
Reordering DISTINCT keys to match input path's pathkeys
The ordering of DISTINCT items is semantically insignificant, so we
can reorder them as needed. In fact, in the parser, we absorb the
sorting semantics of the sortClause as much as possible into the
distinctClause, ensuring that one clause is a prefix of the other.
This can help avoid a possible need to re-sort.
In this commit, we attempt to adjust the DISTINCT keys to match the
input path's pathkeys. This can likewise help avoid re-sorting, or
allow us to use incremental-sort to save efforts.
For DISTINCT ON expressions, the parser already ensures that they
match the initial ORDER BY expressions. When reordering the DISTINCT
keys, we must ensure that the resulting pathkey list matches the
initial distinctClause pathkeys.
This introduces a new GUC, enable_distinct_reordering, which allows
the optimization to be disabled if needed.
Author: Richard Guo
Reviewed-by: Andrei Lepikhov
Discussion: https://postgr.es/m/CAMbWs48dR26cCcX0f=8bja2JKQPcU64136kHk=xekHT9xschiQ@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index a84e60c09b9..76ab72db964 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -5360,6 +5360,20 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class=" </listitem> </varlistentry> + <varlistentry id="guc-enable-distinct-reordering" xreflabel="enable_distinct_reordering"> + <term><varname>enable_distinct_reordering</varname> (<type>boolean</type>) + <indexterm> + <primary><varname>enable_distinct_reordering</varname> configuration parameter</primary> + </indexterm> + </term> + <listitem> + <para> + Enables or disables the query planner's ability to reorder DISTINCT + keys to match the input path's pathkeys. The default is <literal>on</literal>. + </para> + </listitem> + </varlistentry> + <varlistentry id="guc-enable-gathermerge" xreflabel="enable_gathermerge"> <term><varname>enable_gathermerge</varname> (<type>boolean</type>) <indexterm> |