| From: | Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com> |
|---|---|
| To: | Denis Smirnov <darthunix(at)gmail(dot)com> |
| Cc: | Rustam ALLAKOV <rustamallakov(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> |
| Subject: | Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE |
| Date: | 2026-11-05 10:38:26 |
| Message-ID: | 0c34b127-f638-4817-a2af-bb7fd642cfd2@tantorlabs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 10/20/26 06:14, Denis Smirnov wrote:
> Hi Ilia,
>
> Tested on master at 0497318e442, with and without v7:
>
> create temp table t (a int, b int);
> insert into t
> select i, i from generate_series(1, 100000) i;
>
> create index ti on t (((a not in (42, null)) or b = 1));
> analyze t;
>
> set enable_seqscan = off;
>
> explain (costs off)
> select * from t where (a not in (42, null)) or b = 1;
>
> master: Index Scan using ti on t
> v7: Seq Scan on t
> Disabled: true
> Filter: (b = 1)
>
>
> Best regards,
> Denis Smirnov
>
You're right. Folding removes the never-true clause from OR, so the qual
no longer matches the index expression, which retains that clause. I've
restricted the folding to preserve non constant OR expressions. An OR
whose clauses can all never be TRUE still folds to FALSE. Added
regression tests as well.
--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v8-0001-Fold-never-true-scalar-array-comparisons-to-false.patch | text/x-patch | 58.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayoub Kazar | 2026-11-05 10:55:31 | Re: file_fdw: Fix ANALYZE crashes with DEFAULT markers |
| Previous Message | Ajin Cherian | 2026-11-05 10:38:25 | Re: BUG? Unpublished generated columns are reported "missing" by the subscription |