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 1ty7xK-002lFr-GD for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Mar 2025 11:32:58 +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 1ty7xI-008NS0-UL for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Mar 2025 11:32:56 +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 1ty7xI-008NRr-K7 for pgsql-hackers@lists.postgresql.org; Fri, 28 Mar 2025 11:32:56 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ty7xG-001hGf-1A for pgsql-hackers@lists.postgresql.org; Fri, 28 Mar 2025 11:32:56 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43cec5cd73bso13296855e9.3 for ; Fri, 28 Mar 2025 04:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743161573; x=1743766373; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=sYRZUG2I6fjspzHLOum/9kVRA7I+/z/dGfoQhonJqTA=; b=bjgkBZXhUjBUBRct7fJ8DfOlyf3QJRLS1RYGEuCgCyRQju3H5VxJJooUC0RR/+84na 3W3htd1YIhnPEpqqdVzwe37gq5TQLGsA4H+MieKVJ4UCbEZ5Y8rJOFG/F+LN1JZRiBYk gpb4yxfXUE675INB01TdtA0Lv2S1jDTfMosJz/rvGTEjDVGg/XFWi1kBKmKL+NbOl1EE 2kkYKs4Zir98d5R2IQ7UoKq7SZif81hf3qChU/T1JRZ+VaPeoFhqhk6hxxXUlJBYkmgR 9r7yEQB8soUpTAEd/r1mMcEvnT1+R8pQmpPczrwDFhHowH+8Fos+HmGtRXQ2xLR/xo2q 6fNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743161573; x=1743766373; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sYRZUG2I6fjspzHLOum/9kVRA7I+/z/dGfoQhonJqTA=; b=t2gA9eGCxGKazXLayhuGO8seOWVQf7zw0Kzy8id78U64pxe8fUmCo7sDOONeBQYMxf HMbN5Ucchx8U8vOQOGi6D/QjOgji9BY3OvIqKldkozm9nLT+W12mDO2zGGBSiyjHqrwW bGWdw+0XsTp4uFk07Mx2iAq0CdRtWf0xk+w7vEbaPoKBF3FvHzGq6g8xMB9JAQ7asCNp ZH3qOxt6R+2yWZRKFryEVjEHh3uxM2YyG+g8B61At+KCZ0ulecz/hbUkIfeO/QcU5+Ci 3eWd4l6IHBWLi0gKq7L4cfY5QnlBG1Esif4eO8RwKW/QAbLS2c4Vmpsp3v5X2cV5ta91 YQPw== X-Forwarded-Encrypted: i=1; AJvYcCVzLj2k+Z9CVuzg7LrM0R+cYG4LtA0ZhghFYSSIu7SVwpXbwYKB+VPxGAeLmgBpfcRIXVw6FEzZbUpJVlp3@lists.postgresql.org X-Gm-Message-State: AOJu0YxPaKv28bPwpuG/sn6aHoXlUYTUsZlwqd3IO5sV3eTp6DbPbxdb SvUr7oXVcoJQLfEp7NL2tpO7haxpeEgmluYrizRQoGKEICnoOo9D X-Gm-Gg: ASbGnct5nlx9hVgOkoN+X2+ahwPVnC2MmsgKC2EWuEZvGFB7aowS26gBlXxIQZBCyOJ FNx73U7TZbFxxcwaP6dZi7GIJNtLba4KU6gsuljNcQJ77x22TJlWOIsQH30Fxzyk3hnDsH82G8W m9xKcmPjiJO4EToyf/bwFi5RPUiVI99ZcHVWHig4qbLHguVrt9pGAgSONIZ6R+PRQpNwK2hRQYs XVzUNlFcbzqWZENpFtR3F3BMSy2+1OXb6CTlSyMa25if9S2UAwmacCRWj0hImNxVAhtB7VW9B0y anXu2scAWRD2YyKZPLDviigohPdowbGeYzzJvJeD1Y9kMtEMtQAVEmafcMj2b9jqQJgxzOy/lg9 A5qNGPWv/GkZgHQ== X-Google-Smtp-Source: AGHT+IFEDzwFXccv8G22y+RwVAPawmMShYwTVhpOZnARlLNleBkGdlvUWoyRVm29EkfC7jNx8g38HQ== X-Received: by 2002:a05:600c:4c04:b0:43b:c5a3:2e1a with SMTP id 5b1f17b1804b1-43d8522cdcbmr48550655e9.2.1743161572626; Fri, 28 Mar 2025 04:32:52 -0700 (PDT) Received: from [192.168.0.89] (84.123.232.230.dyn.user.ono.com. [84.123.232.230]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b79e0afsm2344527f8f.65.2025.03.28.04.32.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Mar 2025 04:32:52 -0700 (PDT) Message-ID: <0db3c58a-0336-456b-8ae9-a8e5154ee7a5@gmail.com> Date: Fri, 28 Mar 2025 12:32:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes To: Alexander Korotkov , Alena Rybakina Cc: Pavel Borisov , Alexander Lakhin , pgsql-hackers@lists.postgresql.org References: <567ED6CA.2040504@sigaev.ru> <41ba3d47-2a48-476c-88d4-6ebd889a7af2@gmail.com> <036d64e6-4d47-485c-b047-6664d452b3e8@postgrespro.ru> <1a4f1631-86c1-4185-a520-03b24a389449@postgrespro.ru> <3ac7c436-81e1-4191-9caf-b0dd70b51511@gmail.com> <72eab2bf-7f94-4f58-84bc-2b80d74b6443@postgrespro.ru> Content-Language: en-AU From: Andrei Lepikhov 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 3/28/25 00:18, Alexander Korotkov wrote: > The attached patch changes the reordering algorithm of > group_similar_or_args() in the following way. We reorder each group > of similar clauses so that the first item of the group stays in place, > but all the other items are moved after it. So, if there are no > similar clauses, the order of clauses stays the same. When there are > some groups, only required reordering happens while the rest of the > clauses remain in their places. The patch looks good to me from a technical perspective. But it seems like an overkill, isn't it? You introduce additional CPU-consuming operations in the planning OR operations. My point is: 1) as Pavel has mentioned, Postgres doesn't guarantee the evaluation/output order of the clauses at all. 2) we need that to keep regression tests stable (don't forget extensions' and forks' developers too). But it should be done once if we have no fluidity in OR clauses order in general. The trade-off with tricky query writers and regression tests may be preserving the order until OR->ANY has happened. If it has happened, just ensure the order is determined somehow. Except that, any other spending on CPU cycles seems too expensive. -- regards, Andrei Lepikhov