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 1wzD18-003sOJ-2s for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Aug 2026 12:46:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wzD17-00D1wi-2i for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Aug 2026 12:46:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzD17-00D1wa-0T for pgsql-hackers@lists.postgresql.org; Wed, 26 Aug 2026 12:46:09 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wzD14-00000001Mqs-2FhP for pgsql-hackers@lists.postgresql.org; Wed, 26 Aug 2026 12:46:08 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 8DABE1D00081; Wed, 26 Aug 2026 08:46:03 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Wed, 26 Aug 2026 08:46:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1787748363; x=1787834763; bh=zuKBqw3Xah wNusGjQuyz2yM7WwqZSY2vqIAoOjxxP6Y=; b=DHa+WHaapmAtVV+wr13wY38Jj0 Mvpw8BWtk40Roganmd/kca82/1tZ9EcYed80wuea09RVq7ziq+NiO+mowST+oJi1 ga3YTG38jXsqpUEus7y+qi9D3g6BKs9vh1RsuaWwM4TXCsp78ez6ht9dXCUc+UVq 2jM/kbj6XIJE9zLV2r2qAHQLxq1nQJtzDpUU6xD46TM6qwpee7Dt3ZRSHRgPIXVU A+6R9P/gVBUtpSr092bke2Y5FmJcH5VofZGvBJrsNHIhKl1P46JS4D70ioxBwYtC JirWHvI/FCvVjFA1q1Z1gg4LZD8f2v+HXfZ1Ag+H1pbJ9mTlAriLAYMSo6/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1787748363; x=1787834763; bh=zuKBqw3XahwNusGjQuyz2yM7WwqZSY2vqIA oOjxxP6Y=; b=jXNT71m7Nn5SjNIil/+n+ULHPfTc4SMaOHsMQDOxEuGq2cUV2iG adYQr3PAQr95q2L3idrnSBPKcB7zqNShRGa0gd04yvrgTI241X/ju3vFFRSHt93J bu6jnhH2fGjj2MhtIGI8khg7nGqj05VNWf2LdpTRFMFP/nj2Cn1JnjscXnKxakpB /GcoHjzETjD+WtEi1OFzGqsbMhHXp0xPlMKQoVA8FR8I+A98ycomT2oIbwlAkc3U JC5mEJnpsMtdb1E2bcyOq04yS/X5Qbp87KPdTEZKLOKXELt/JQtMwJQVdvbyygT9 ITBFXeW2Oz8VhBCoEfBhpXKkoxZUbrpaKvg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFiCH/klChK6h8BmOgs/+V/o3Xv5FywzNarMPmkpAy79OpIasiosFzNcOVQElz/qw M0EywXA1ZY0sHncrUDpyJSlWeFkmRB5apEsm72z+N7ZXodxKNVep63FMujBADKplZLZKQ3 vL5sb5atxJ5bnLS/tAwn5sadQavZlNMAk4VEL1+NOyhnKu5JB/gZYIgJ0+ts2yWfZ4De9a D38XkyO2tOSujKjXsMPHehP7YwuFP4T8rlgnOOlbwgbOPd1fOCrvJUVaIvlk6UwciHj3yU ybviyo1eUZ2k3TEfjCejJjD7ywsHpqmNVBjeLB63zAP8GK62hKx78HoWE0KInfN340g8ek 8s8P5+EkEQQb7OD399Rkfst9lnlSlO1qyosNyAz3PEwr4hL9sRr3d10QWbhPAQbdKt6158 Q5yczDKWnto9DdH/+DXgKzrX8WXWTkG1GMAKoG84lyj3DgwfCw9mqnbDxy4xStbM6fULHO tY20vYAm2EI4ZRfslMhWsQtf1HLG2xh7SS9K7id+4S2eCYfpiqSN+1dMNs6Yh+QdDKk+f/ G9H2lJv3O/heJ8ER12RhS+FQfwCXV8fnwQBLemDfNNiKfz30jfgruv0XdhR72mFOpf6hV4 KBYEbjDCFo0t9/0bi8iG6Ngrw/1uWj8PDav9DPajo5vqeZAO+1Iz/28NMLLQ X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 26 Aug 2026 08:46:02 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: William Bernbaum Cc: "guofenglinux@gmail.com" , "pgsql-hackers@lists.postgresql.org" Subject: Re: Skipping NULL keys when uniqueifying a semijoin's RHS References: Date: Wed, 26 Aug 2026 13:46:01 +0100 In-Reply-To: (William Bernbaum's message of "Tue, 25 Aug 2026 14:27:07 +0000") Message-ID: <878q5tyrqu.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk William Bernbaum writes: > The attached patch adds a pass, add_semijoin_not_null_quals(), > which runs before set_base_rel_sizes(), that walks > root->join_info_list, and, for each semijoin whose > righthand keys can be unique-ified, pushes an IS NOT NULL > restriction down onto the key. I'm by no means an expert on the planner, but the idea seems sound to me, and on the surface the change looks sensible. I have just a couple of code nitpicks: > + ListCell *lc; > + > + foreach(lc, root->join_info_list) > + { > + SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) lfirst(lc); This should be foreach_node(SpecialJoinInfo, sjinfo, root->join_info_list). > + ListCell *lc2; [...] > + foreach(lc2, sjinfo->semi_rhs_exprs) > + { > + Expr *expr = (Expr *) lfirst(lc2); And this should be foreach_node(Expr, expr, sjinfo->semi_rhs_exprs). - ilmari