Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vunaP-0073Zs-1c for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 08:16:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vunaO-0006tz-14 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Feb 2026 08:16:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vunaN-0006tr-2m for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 08:16:04 +0000 Received: from forward500b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:d500]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vunaJ-00000000vfm-1K1u for pgsql-hackers@lists.postgresql.org; Tue, 24 Feb 2026 08:16:02 +0000 Received: from mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net [IPv6:2a02:6b8:c1c:405:0:640:8814:0]) by forward500b.mail.yandex.net (Yandex) with ESMTPS id 3E2F6C1412; Tue, 24 Feb 2026 11:15:55 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id sFbqNFZGpCg0-sai75g1w; Tue, 24 Feb 2026 11:15:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1771920954; bh=YVzbSyqaZXXjNmMC6OALpynKR4D1LL4UEuyGcxudZzg=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=IZZrPM5FUE/mSaK4lPy/bnbsjg50H1/9lfhixCdQ4Dqf82/ZnQ6tdo3Cg8R5jSb0T rO6/nGD2thafxDCE79qwgygE3OxpXjXN0f9B/XVQ7fne0ilgSWhjgP3JvKZjVGAACr QOvDFZccvBghwhpc533ukR8Ibj6EP82bzPISBCTo= Authentication-Results: mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: <52f3c637-465d-4f0e-9546-732ecf61ab87@tantorlabs.com> Date: Tue, 24 Feb 2026 11:15:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Reduce planning time for large NOT IN lists containing NULL To: Zsolt Parragi Cc: David Geier , PostgreSQL Developers References: <52596e08-0902-475b-ad0f-265ec6918f19@gmail.com> <7791ec74-369d-48c7-969c-cf4ad18024f2@tantorlabs.com> <6b3aebb5-f26c-4f50-abd6-e733d452af26@gmail.com> Content-Language: en-US From: Ilia Evdokimov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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/