pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Guo <rguo@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove redundant restriction checks in apply_child_basequals
Date: Wed, 04 Mar 2026 01:59:30 +0000
Message-ID: <E1vxbWM-002GvH-20@gemulon.postgresql.org> (raw)

Remove redundant restriction checks in apply_child_basequals

In apply_child_basequals, after translating a parent relation's
restriction quals for a child relation, we simplify each child qual by
calling eval_const_expressions.  Historically, the code then called
restriction_is_always_false and restriction_is_always_true to reduce
NullTest quals that are provably false or true.

However, since commit e2debb643, the planner natively performs
NullTest deduction during constant folding.  Therefore, calling
restriction_is_always_false and restriction_is_always_true immediately
afterward is redundant and wastes CPU cycles.  We can safely remove
them and simply rely on the constant folding to handle the deduction.

Author: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CAMbWs4-vLmGXaUEZyOMacN0BVfqWCt2tM-eDVWdDfJnOQaauGg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1f4f87d79436cd04d549b3ad0a141a7a3adca28c

Modified Files
--------------
src/backend/optimizer/util/inherit.c | 12 ++----------
src/backend/optimizer/util/relnode.c | 26 +++++++++++---------------
2 files changed, 13 insertions(+), 25 deletions(-)



Message-ID: <E1vxbWM-002GvH-20@gemulon.postgresql.org>
Permalink:  ../E1vxbWM-002GvH-20@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vxbWM-002GvH-20@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: rguo@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Remove redundant restriction checks in apply_child_basequals
  In-Reply-To: <E1vxbWM-002GvH-20@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