Re: Reduce planning time for large NOT IN lists containing NULL
David Geier <geidav.pg@gmail.com>
From: David Geier <geidav.pg@gmail.com>
To: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2026-02-20T14:22:20Z
Lists: pgsql-hackers
On 20.02.2026 14:28, Ilia Evdokimov wrote: > On 2/20/26 16:25, Ilia Evdokimov wrote: > >> I've moved the NULL check higher, placing it immediately after >> DatumGetArrayTypeP(). This allows us to detect the presence of NULL >> elements before decontructing the array. >> > Sorry, I forgot to attach the patch in my previous mail. Attaching it now. Cool that the array code had that functionality already. The patch looks good to me and now no longer regresses other cases. The speedup will be less pronounced once the hash-based [NOT] IN code is merged [1] but will still save considerable amounts of cycles. It seems like we don't have a regression test which has a NULL value in the NOT IN list. Maybe you can find a good place to add that one? -- David Geier [1] https://www.postgresql.org/message-id/flat/7db341e0-fbc6-4ec5-922c-11fdafe7be12%40tantorlabs.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