pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix usage of the parse tree for estimate_num_groups() in set ope
Date: Sat, 04 Nov 2023 01:30:29 +0000
Message-ID: <E1qz5Ub-003pkj-CP@gemulon.postgresql.org> (raw)

Fix usage of the parse tree for estimate_num_groups() in set operations

recurse_set_operations() uses the parse tree for the group number estimation,
because of the "varno 0" hack.  At the same time 2489d76c49 made root->parse
and corresponding parent_root->simple_rte_array[]->subquery distinct copies
of the parse tree, while d3d55ce571 introduced self-join removal replacing
relid of removed relation only in one of the copies.

The present commit fixes this bug by making recurse_set_operations() call
estimate_num_groups() with the copy of the parse tree processed by self-join
removal.

In future, we may think about maintaining just one copy of the parse tree
and/or keeping removed relids as aliases.

Reported-by: Zuming Jiang
Bug: #18170
Discussion: https://postgr.es/m/flat/18170-f1d17bf9a0d58b24%40postgresql.org
Author: Richard Guo, Alexander Korotkov
Reviewed-by: Andrei Lepikhov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ec63622c03ff7be36d32c08aaa7d853856451488

Modified Files
--------------
src/backend/optimizer/prep/prepunion.c |  7 +++++--
src/test/regress/expected/join.out     | 17 +++++++++++++++++
src/test/regress/sql/join.sql          |  7 +++++++
3 files changed, 29 insertions(+), 2 deletions(-)



Message-ID: <E1qz5Ub-003pkj-CP@gemulon.postgresql.org>
Permalink:  ../E1qz5Ub-003pkj-CP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qz5Ub-003pkj-CP@gemulon.postgresql.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix usage of the parse tree for estimate_num_groups() in set ope
  In-Reply-To: <E1qz5Ub-003pkj-CP@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