From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix cost_incremental_sort for expressions with varno 0
Date: Wed, 22 Apr 2020 22:44:55 +0000
Message-ID: <E1jRO6x-0001Xt-6m@gemulon.postgresql.org> (raw)
Fix cost_incremental_sort for expressions with varno 0
When estimating the number of pre-sorted groups in cost_incremental_sort
we must not pass Vars with varno 0 to estimate_num_groups, which would
cause failues in find_base_rel. This may happen when sorting output of
set operations, thanks to generate_append_tlist.
Unlike recurse_set_operations we can't easily access the original target
list, so if we find any Vars with varno 0, we fall back to the default
estimate DEFAULT_NUM_DISTINCT.
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/20200411214639.GK2228%40telsasoft.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/de0dc1a84710f127fdd40f87e783797cc2d69a77
Modified Files
--------------
src/backend/optimizer/path/costsize.c | 54 ++++++++++++++++++++++++--
src/test/regress/expected/incremental_sort.out | 20 ++++++++++
src/test/regress/sql/incremental_sort.sql | 4 ++
3 files changed, 75 insertions(+), 3 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tomas.vondra@postgresql.org
Subject: Re: pgsql: Fix cost_incremental_sort for expressions with varno 0
In-Reply-To: <E1jRO6x-0001Xt-6m@gemulon.postgresql.org>
References: <E1jRO6x-0001Xt-6m@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox