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 1vvXBf-006hW6-1t for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2026 08:57:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvXBd-00BNDQ-0T for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Feb 2026 08:57:33 +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 1vvXBc-00BNDG-26 for pgsql-hackers@lists.postgresql.org; Thu, 26 Feb 2026 08:57:32 +0000 Received: from forward501a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d501]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vvXBZ-00000001MaY-0Vy8 for pgsql-hackers@lists.postgresql.org; Thu, 26 Feb 2026 08:57:32 +0000 Received: from mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:582e:0:640:200:0]) by forward501a.mail.yandex.net (Yandex) with ESMTPS id C6FB380C90; Thu, 26 Feb 2026 11:57:27 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id Qvdmal0G7Cg0-JmfOHfBz; Thu, 26 Feb 2026 11:57:27 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1772096247; bh=w0w1V2et8TT0C4CQ1byKXd4DDRv7DagEI6qdeV7ZbeQ=; h=In-Reply-To:Cc:Date:References:To:From:Subject:Message-ID; b=TzdEYw74J4XWROXZd/TfJp/4DtL7AkQW0l31Bn2DePrupj6cr7/UHHfq8U7m7+0Fb 14c9PbQgdcK8kMOZyM+79SoDxPWzd0V57HkB1ltXSOh7Sjjf9yd2PqJITVJw3+scsD JUuXWcPQ03qjTnbY3Bmjkgo6SRhv34X/D3mI307U= Authentication-Results: mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: Date: Thu, 26 Feb 2026 11:57:26 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Hash-based MCV matching for large IN-lists From: Ilia Evdokimov To: Zsolt Parragi Cc: Tatsuya Kawata , David Geier , Chengpeng Yan , "pgsql-hackers@lists.postgresql.org" References: <7db341e0-fbc6-4ec5-922c-11fdafe7be12@tantorlabs.com> <988e3168-6096-488a-bb42-787e1e8c21a4@tantorlabs.com> <21FF6A0B-886F-4132-B6A6-0F4E934B4CEE@Outlook.com> <8ee9d903-bb13-434c-8145-b3769bf2b3cb@tantorlabs.com> <9e3054ae-1c5d-46dd-9b6a-7fb67764b076@tantorlabs.com> <9067a807-f130-4631-8df4-076c6d7e43b6@tantorlabs.com> Content-Language: en-US In-Reply-To: <9067a807-f130-4631-8df4-076c6d7e43b6@tantorlabs.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/26/26 01:45, Ilia Evdokimov wrote: > About op_is_reserved. It seems we should assign op_is_reserved = true, > because we don't reverse types like eqjoinsel_semi(). If IN-list > smaller than MCV-list we reverse it by fmgr_info(hash_mcv ? hashLeft : > hashRight, &hash_proc). Thanks for this remark. > I guess I rushed to conclusions. This assignment op_is_reversed = true was incorrect. During lookups, simplehash passes: key0 as the value stored in the hash table, key1 as the probe value. Since MCV entries correspond to the variable's statistics, the correct argument order depends on which side we build the hash table on. If we hash MCV values (hash_mcv = true), then key0 = MCV value, key1 = IN-list value, so we must call operator(key0, key1). If we hash IN-list elements (hash_mcv = fasle), then key0 = IN-list value, key1 = MCV value and we must call operator(key1, key0). Therefore the correct assignment is hashContext.op_is_reversed = hash_mcv. If you have another suggestions to v6 patches, send them, and I'll fix them with hashContext.op_is_reversed = hash_mcv. -- Best regards, Ilia Evdokimov, Tantor Labs LLC, https://tantorlabs.com/