Remove redundant restriction checks in apply_child_basequals

Richard Guo <rguo@postgresql.org>

Commit: 1f4f87d79436cd04d549b3ad0a141a7a3adca28c
Author: Richard Guo <rguo@postgresql.org>
Date: 2026-03-04T01:57:43Z
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

Files

PathChange+/−
src/backend/optimizer/util/inherit.c modified +2 −10
src/backend/optimizer/util/relnode.c modified +11 −15

Discussion