From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, bryfox(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #19007: Planner fails to choose partial index with spurious 'not null' |
Date: | 2025-08-22 07:25:25 |
Message-ID: | CAMbWs48x=GsGan_bvQ+j0rLqYFNi9W725EmJpWUZv1RrmaicZQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Wed, Aug 20, 2025 at 6:37 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> I've had some time to look at this issue again. There are several
> cases in plancat.c where specific expressions need to be run through
> eval_const_expressions because the planner will be comparing them to
> similarly-processed qual clauses. This includes constraint
> expressions, statistics expressions, index expressions and index
> predicates -- as highlighted by this bug report.
I've split the patch into two. 0001 fixes const-simplification for
constraint expressions and statistics expressions by ensuring that
Vars are updated to have the correct varno before
const-simplification, and that a valid root is passed to
eval_const_expressions. 0002 fixes const-simplification for index
expressions and predicate by running eval_const_expressions a second
time after the Vars have been fixed and with a valid root.
I think 0001 is in pretty good shape. I'm concerned that in 0002 we
have to run eval_const_expressions twice. I once considered caching
the untransformed index expressions and predicate, and running
const-simplification outside of relcache.c. However, that doesn't
seem like a better solution, since we would need to re-run
const-simplification every time we fetch the index expressions and
predicate. Any suggestions?
Thanks
Richard
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Fix-const-simplification-for-constraints-and-stat.patch | application/octet-stream | 7.9 KB |
v2-0002-Fix-const-simplification-for-index-expressions-an.patch | application/octet-stream | 7.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Etsuro Fujita | 2025-08-22 10:59:40 | Re: TRAP: failed Assert("outerPlan != NULL") in postgres_fdw.c |
Previous Message | Xuneng Zhou | 2025-08-22 03:25:47 | Re: BUG #19006: Assert(BufferIsPinned) in BufferGetBlockNumber() is triggered for forwarded buffer |