Re: Reduce planning time for large NOT IN lists containing NULL
Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
From: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>,
David Geier <geidav.pg@gmail.com>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-18T14:26:51Z
Lists: pgsql-hackers
Attachments
- v9-0001-Reduce-planning-time-for-large-NOT-IN-lists-conta.patch (text/x-patch) patch v9-0001
On 3/18/26 07:32, David Rowley wrote: > Thanks. I've pushed 0001. > > I ended up renaming the new file to planner_est.sql as the function > handles width estimate masking too, so I thought just calling it > selectivity_est was a bit too restrictive. I went with planner_est. +1. Thank you. > That means 0002 needed rebased. I've done that in the attached. After the new test was committed, I realized that v8 tests relies on selectivity calculation, which are not guaranteed to remain stable over time and way vary depending on planner heuristics or platform differences. Therefore, it seems better to remove tests from v8. Instead, we can test the invariant behavior: when NULL is present in a <> ALL clause, the selectivity is always 0.0. The v9-patch adds three test cases: a degenerate case with only NULL, NULL combined with constants, NULL combined with both constants and non-constant expression. Thoughts? -- Best regards, Ilia Evdokimov, Tantor Labs LLC, https://tantorlabs.com/
Commits
-
Short-circuit row estimation in NOT IN containing NULL consts
- c95cd2991f1e 19 (unreleased) landed
-
Move planner row-estimation tests to new planner_est.sql
- 374a6394c6ae 19 (unreleased) landed