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-26T09:20:45Z
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
- v4-0001-Fix-const-simplification-for-index-expressions-an.patch (application/octet-stream) patch v4-0001
On Mon, Sep 1, 2025 at 3:00 PM Richard Guo <guofenglinux@gmail.com> wrote: > 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. Here is an updated version of the patch. In the commit message, I've explained why I think the additional call to eval_const_expressions is not a performance concern. I've also added a test case to validate that NullTest quals in index expressions can now be reduced. One concern I have is that this fix can only be applied to master; there's no way to backpatch it to v17 or v18. This means that the issue won't exist in v16 or earlier, nor in v19 and later, but it will persist in v17 and v18. I have no idea what we should do for v17 and v18. - Richard