Re: Reduce planning time for large NOT IN lists containing NULL

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, 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-03-18 14:26:51
Message-ID: 83464ae9-a79a-43c8-a425-4b0773f9e759@tantorlabs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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/

Attachment Content-Type Size
v9-0001-Reduce-planning-time-for-large-NOT-IN-lists-conta.patch text/x-patch 4.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-03-18 14:33:36 Re: Serverside SNI support in libpq
Previous Message Andres Freund 2026-03-18 14:26:26 Re: Read-only connection mode for AI workflows.