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 1ty8s9-002xdQ-5j for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Mar 2025 12:31:41 +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 1ty8s7-009IiU-SZ for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Mar 2025 12:31:39 +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 1ty8s7-009Ihm-Cz for pgsql-hackers@lists.postgresql.org; Fri, 28 Mar 2025 12:31:39 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ty8s4-001cbk-2o for pgsql-hackers@lists.postgresql.org; Fri, 28 Mar 2025 12:31:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1743165094; bh=oE+x26BYhst2TIgTxOUC/mDgRqAis2PXg1wYXsxGl+c=; h=Message-ID:Date:User-Agent:Subject:From:To:Cc:References: In-Reply-To:From; b=c63hi/TTb2CsR5LQ2nQyCWMbOeMhoStcGlLRSRAofc5/Gn4k53ac5U3/5Wr52EEOA Kbic5Qp0cUSJw6+FPvlBDiz1rejZhF+5yGZSTujT9+y1BoKpnSZc7hJJjMEtNaiCi6 VAPRgTrowMii6fjY922qMdOT3oonZi/CYR45qgkTVekldd5nu21faSecock7kaCN7C cnJep60kWfGCO68VlqeoW9KNeCtXDg3+Va0YGS7SkCSF82RkXUuiQHLsuZj4YPdXS3 rICs3hnr0rWPDsWaaWnk4WHkGZgNCqlrMM8zdLAu1CTZ90h3DgoeqOA6F1TMZG062K gpjQwI7jeghPw== Received: from [10.0.85.1] (unknown [188.214.33.78]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.rybakina@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 64F616018F; Fri, 28 Mar 2025 15:31:33 +0300 (MSK) Content-Type: multipart/alternative; boundary="------------IUGo6AL1IN9VbKBQDRUD7vna" Message-ID: Date: Fri, 28 Mar 2025 15:31:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: POC, WIP: OR-clause support for indexes From: Alena Rybakina To: Alexander Korotkov Cc: Pavel Borisov , Andrei Lepikhov , 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-US In-Reply-To: X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/03/28 11:27:00 #27851261 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------IUGo6AL1IN9VbKBQDRUD7vna Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 28.03.2025 15:23, Alena Rybakina wrote: > > I agree with your code in general, but to be honest, double qsort > confused me a little. > > I understood why it is needed - we need to sort the elements so that > they stand next to each other if they can be assigned to the same > group, and then sort the groups themselves according to the set > identifier. > > I may be missing something, but in the worst case we can get the > complexity of qsort O(n^2), right? And I saw the letter where you > mentioned this, but it is possible to use mergesort algorithm  instead > of qsort, which in the worst case gives n * O(n) complexity? > No, sorry, I was wrong here and it is impossible to rewrite it this way. I apologize, I agree with your code. -- Regards, Alena Rybakina Postgres Professional --------------IUGo6AL1IN9VbKBQDRUD7vna Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 28.03.2025 15:23, Alena Rybakina wrote:

I agree with your code in general, but to be honest, double qsort confused me a little. 

I understood why it is needed - we need to sort the elements so that they stand next to each other if they can be assigned to the same group, and then sort the groups themselves according to the set identifier. 

I may be missing something, but in the worst case we can get the complexity of qsort O(n^2), right? And I saw the letter where you mentioned this, but it is possible to use mergesort algorithm  instead of qsort, which in the worst case gives n * O(n) complexity?


    
No, sorry, I was wrong here and it is impossible to rewrite it this way. I apologize, I agree with your code.
-- 
Regards,
Alena Rybakina
Postgres Professional
--------------IUGo6AL1IN9VbKBQDRUD7vna--