Re: BUG #19007: Planner fails to choose partial index with spurious 'not null'
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, bryfox@gmail.com,
pgsql-bugs@lists.postgresql.org
Date: 2025-09-01T06:00:03Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix const-simplification for index expressions and predicate
- c925ad30b047 19 (unreleased) landed
-
Fix const-simplification for constraints and stats
- 317c117d6d23 19 (unreleased) landed
Attachments
- v3-0001-Fix-const-simplification-for-index-expressions-an.patch (application/octet-stream) patch v3-0001
On Fri, Aug 22, 2025 at 4:25 PM Richard Guo <guofenglinux@gmail.com> wrote: > 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? 0001 has been pushed; here is a rebase of 0002. I think the additional call to eval_const_expressions() is acceptable performance-wise, because 1) it only runs when index expressions or predicates are present, and 2) it's relatively cheap when run on small expression trees, which is typically the case for index expressions and predicates. In return, in cases such as the reported, it enables the planner to match and use partial indexes, which can be a big win in execution. - Richard