| From: | Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com> |
|---|---|
| To: | David Geier <geidav(dot)pg(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Reduce planning time for large NOT IN lists containing NULL |
| Date: | 2026-02-20 13:25:24 |
| Message-ID: | ed61316c-2e48-45d1-9cca-dc539bfd93b9@tantorlabs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2/20/26 12:06, Ilia Evdokimov wrote:
> There is already ARR_HASNULL() which allows us to detect the presence
> of NULL in ArrayType.
>
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.
I tested this with several queries of the form:
WHERE x NOT IN (NULL, ...)
In my tests (with column x having detailed statistics, so selectivity
estimation performs more work), planning time decreases from *5-200 ms
before the patch* to *~ 1-2 ms after the patch*, depending on the list size.
--
Best regards.
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ilia Evdokimov | 2026-02-20 13:28:57 | Re: Reduce planning time for large NOT IN lists containing NULL |
| Previous Message | Andrew Dunstan | 2026-02-20 13:24:25 | Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement |