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.94.2) (envelope-from ) id 1rcHlP-001yfo-MZ for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 04:29:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rcHlN-000wEY-TN for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Feb 2024 04:29:49 +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.94.2) (envelope-from ) id 1rcHlN-000wEQ-GD for pgsql-hackers@lists.postgresql.org; Tue, 20 Feb 2024 04:29:49 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcHlJ-007d7Y-Rt for pgsql-hackers@postgresql.org; Tue, 20 Feb 2024 04:29:48 +0000 Received: from [172.30.8.38] (unknown [172.30.8.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.lepikhov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 3B27AE20E24; Tue, 20 Feb 2024 07:29:38 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1708403383; bh=mtRIiob7ZTEpX52evDiFufCTEYwCvBQ6O2FeM9SOD70=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=jmYUZeRQAl+uQVcihenpuRELh0QrUOBLvUio4dpCAYz3RoY+k2VhXq3RSL12CP8vs tV1AcK8an9pQvzIlRKKz4VNeprPTzpaOUxXvNN9paGMvHP0ienvEnbw4pdC22BkXmO yKhMFLYP3iaI/yjXvUFC9KHEknTyMJalMEvDV/HYLikbuVfHWzh/yK2hlWfzJRKkso pTCjxF9MzMf9pMikDyTAne93cwyPNEVRvtu4JJd6ZjiKyLdJFpT7IYDLpmSGSomSMk shmAJ/1WpyJXQUxZcFL+4UfsbzhpLfi1KgXKZKVhZOf01iP31rBahtUv41jC2rfW+K pR6oJAbi4rjpQ== Message-ID: Date: Tue, 20 Feb 2024 11:29:36 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes Content-Language: en-US To: jian he Cc: Alena Rybakina , Alexander Korotkov , Robert Haas , pgsql-hackers@postgresql.org, Peter Geoghegan , "Finnerty, Jim" , Marcos Pegoraro , teodor@sigaev.ru, Ranier Vilela , Tomas Vondra , Peter Eisentraut References: <567ED6CA.2040504@sigaev.ru> <7e11e27b-7ab9-4d59-af0a-a921861a9206@postgrespro.ru> <13ad923a-33df-4b44-9e00-c9323cd4c37d@postgrespro.ru> <1cf6b382-6e27-4268-9f2a-54ada66eb2eb@postgrespro.ru> <5f119769-ab11-4807-abcc-71d5dd914ea0@postgrespro.ru> From: Andrei Lepikhov Organization: Postgres Professional 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 On 20/2/2024 11:03, jian he wrote: >> Neither the code comments nor the commit message really explain the >> design idea here. That's unfortunate, principally because it makes >> review difficult. >> >> I'm very skeptical about the idea of using JumbleExpr for any part of >> this. It seems fairly expensive, and it might produce false matches. >> If expensive is OK, then why not just use equal()? If it's not, then >> this probably isn't really OK either. But in any case there should be >> comments explaining why this strategy was chosen. > > The above message > (https://postgr.es/m/CA%2BTgmoZCgP6FrBQEusn4yaWm02XU8OPeoEMk91q7PRBgwaAkFw%40mail.gmail.com) > seems still not answered. > How can we evaluate whether JumbleExpr is expensive or not? > I used this naive script to test, but didn't find a big difference > when enable_or_transformation is ON or OFF. First, I am open to discussion here. But IMO, equal() operation is quite expensive by itself. We should use the hash table approach to avoid quadratic behaviour when looking for similar clauses in the 'OR' list. Moreover, we use equal() in many places: selectivity estimations, proving of fitting the index, predtest, etc. So, by reducing the clause list, we eliminate many calls of the equal() routine, too. > `leftop operator rightop` > the operator can also be volatile. > Do we need to check (op_volatile(opno) == PROVOLATILE_VOLATILE) within > transformBoolExprOr? As usual, could you provide a test case to discuss it more objectively? -- regards, Andrei Lepikhov Postgres Professional