| From: | Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com> |
|---|---|
| To: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Cc: | 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-24 08:15:54 |
| Message-ID: | 52f3c637-465d-4f0e-9546-732ecf61ab87@tantorlabs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On 2/23/26 22:44, Zsolt Parragi wrote:
> Hello
>
> I think it would be a good idea to add a test, I think there's a
> regression with this patch:
>
> CREATE TABLE notin_test AS SELECT generate_series(1, 1000) AS x;
> ANALYZE notin_test;
>
> CREATE FUNCTION replace_elem(arr int[], idx int, val int)
> RETURNS int[] AS $$
> BEGIN
> arr[idx] := val;
> RETURN arr;
> END;
> $$ LANGUAGE plpgsql IMMUTABLE;
>
> EXPLAIN SELECT * FROM notin_test WHERE x <> ALL(ARRAY[1,99,3]);
> -- same array, constructed from an array with a NULL
> EXPLAIN SELECT * FROM notin_test WHERE x <>
> ALL(replace_elem(ARRAY[1,NULL,3], 2, 99));
> DROP TABLE notin_test;
> DROP FUNCTION replace_elem;
>
> ARR_HASNULL probably should be array_contains_nulls, as ARR_HASNULL
> simply checks for the existence of a NULL bitmap.
Could you clarify what exactly this additional test meant to verify?
The current patch only introduces an early exit from the expensive
per-element selectivity loop in the <> ALL case when a NULL is detected.
If the goal is to verify the correctness of IN / NOT IN semantics, those
cases already covered in expressions.sql, including scenarios with NULL
elements.
I attached this thread to commitfest:
https://commitfest.postgresql.org/patch/6519/
--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Geier | 2026-02-24 08:29:27 | Re: Reduce planning time for large NOT IN lists containing NULL |
| Previous Message | Richard Guo | 2026-02-24 08:10:23 | Re: Wrong results with grouping sets |