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 1rjXyN-006EbW-2w for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2024 05:13:16 +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 1rjXyL-008thr-F0 for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2024 05:13:13 +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.94.2) (envelope-from ) id 1rjXyL-008the-1M for pgsql-hackers@lists.postgresql.org; Mon, 11 Mar 2024 05:13:13 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjXyI-003ry6-4V for pgsql-hackers@postgresql.org; Mon, 11 Mar 2024 05:13:12 +0000 Received: from [172.30.0.166] (unknown [172.30.0.166]) (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 44290E20520; Mon, 11 Mar 2024 08:13:05 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1710133988; bh=kmg+TFpvu5X7t3qijcWtnzOwPF+TF/nSo1iuohHM82I=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=jnLHfYiInoThE2uw73iKRtBcyC7UKHyhCIDYWxtt1WakYElTPSBVdfA6YgSjF99Sf jvbF2f6PC22enPv+w5+j/O4+5ihee1KIwH/0+3DS6MdSA9p9vvTpSCgLs+RZ5RMR9G nh2QQVoYfdKxqP/c/UOaj249Y/0sCkb9sN8qEwNu/hiRl6HS2M2bZCBQL6TfocRK2v MgMsamg7AWiH3ekJ6XFO4vGAkVa1SM1c7e64iPFUbIMY9b/V5R4Y5vx+VdoOjf0Rtf doDudtSbfW1AcJl9d0cJZWliNPVXZOTgWyO1tMkve59hrBLUQUjTpHNxr82EfVLNnA 6CbVDwHQ+cGXw== Message-ID: <7389d0dd-05d5-41b7-a12d-2e73f939f851@postgrespro.ru> Date: Mon, 11 Mar 2024 12:13:02 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes Content-Language: en-US To: Alexander Korotkov Cc: jian he , Alena Rybakina , Robert Haas , pgsql-hackers@postgresql.org, Peter Geoghegan , "Finnerty, Jim" , Marcos Pegoraro , teodor@sigaev.ru, Tomas Vondra , Peter Eisentraut , Ranier Vilela References: <567ED6CA.2040504@sigaev.ru> <21088129-7cd3-424a-bcce-6a3427ba3276@postgrespro.ru> <11ee9c04-281f-43c8-a0ff-d481c1e01c09@postgrespro.ru> <54009ba5-4aea-4344-a30d-e3558a59e2a9@postgrespro.ru> <380e5683-cdfd-4220-ab9b-7cccb9d3e480@postgrespro.ru> From: Andrei Lepikhov Organization: Postgres Professional In-Reply-To: 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 7/3/2024 21:51, Alexander Korotkov wrote: > Hi! > > On Tue, Mar 5, 2024 at 9:59 AM Andrei Lepikhov > > wrote: > > On 5/3/2024 12:30, Andrei Lepikhov wrote: > > > On 4/3/2024 09:26, jian he wrote: > > ... and the new version of the patchset is attached. > > I made some revisions for the patchset. Great! > 1) Use hash_combine() to combine hash values. Looks better > 2) Upper limit the number of array elements by MAX_SAOP_ARRAY_SIZE. I'm not convinced about this limit. The initial reason was to combine long lists of ORs into the array because such a transformation made at an early stage increases efficiency. I understand the necessity of this limit in the array decomposition routine but not in the creation one. > 3) Better save the original order of clauses by putting hash entries and > untransformable clauses to the same list.  A lot of differences in > regression tests output have gone. I agree that reducing the number of changes in regression tests looks better. But to achieve this, you introduced a hack that increases the complexity of the code. Is it worth it? Maybe it would be better to make one-time changes in tests instead of getting this burden on board. Or have you meant something more introducing the node type? > We don't make array values unique.  That might make query execution > performance somewhat worse, and also makes selectivity estimation > worse.  I suggest Andrei and/or Alena should implement making array > values unique. The fix Alena has made looks correct. But I urge you to think twice: The optimizer doesn't care about duplicates, so why do we do it? What's more, this optimization is intended to speed up queries with long OR lists. Using the list_append_unique() comparator on such lists could impact performance. I suggest sticking to the common rule and leaving the responsibility on the user's shoulders. At least, we should do this optimization later, in one pass, with sorting elements before building the array. But what if we don't have a sort operator for the type? -- regards, Andrei Lepikhov Postgres Professional