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 1rIKW7-007sQ1-QJ for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Dec 2023 03:23:35 +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 1rIKW4-000p78-Oh for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Dec 2023 03:23:32 +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 1rIKW4-000p70-FT for pgsql-hackers@lists.postgresql.org; Wed, 27 Dec 2023 03:23:32 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIKW2-00E53f-0k for pgsql-hackers@lists.postgresql.org; Wed, 27 Dec 2023 03:23:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3BR3NOmv2414423; Tue, 26 Dec 2023 22:23:25 -0500 From: Tom Lane To: Alexander Korotkov cc: Andrei Lepikhov , PostgreSQL Developers , Tomas Vondra , Teodor Sigaev , David Rowley , "a.rybakina" , =?UTF-8?B?0JHQtdC70Y/Qu9C+0LIg0JTQsNC80LjRgCDQndCw0LjQu9C10LLQuNGH?= Subject: Re: POC: GROUP BY optimization In-reply-to: References: <721b3ff9-f214-f5d4-86c7-bae515bbec18@enterprisedb.com> <7bea462e-8c3e-0f8c-c7d5-f4daa12f3baf@postgrespro.ru> <9af89543-3d17-4c98-59de-1daa5bceeb06@enterprisedb.com> <9408e450-60c6-6fbc-d5c4-467bb0abfe67@postgrespro.ru> <44472925-f6c6-e8de-6f72-0451458532c4@enterprisedb.com> <7a80a207-5e8e-b80c-476c-2d290b0526e9@enterprisedb.com> <65941e87-86c1-c09c-8ad5-8e102aebe8ee@enterprisedb.com> <7256159a-bb83-7ef3-c9c9-b2188a29aaf8@postgrespro.ru> <60610df1-c32f-ebdf-e58c-7a664431f452@enterprisedb.com> <9acd27e9-3372-4d78-b9bc-73e407b8a007@postgrespro.ru> <6c67b7bb-5469-475f-8988-0! a50b4c64852@postgrespro.ru> Comments: In-reply-to Alexander Korotkov message dated "Wed, 27 Dec 2023 04:48:08 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2414421.1703647404.1@sss.pgh.pa.us> Date: Tue, 26 Dec 2023 22:23:24 -0500 Message-ID: <2414422.1703647404@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Korotkov writes: > 2) An accurate estimate of the sorting cost is quite a difficult task. Indeed. > What if we make a simple rule of thumb that sorting integers and > floats is cheaper than sorting numerics and strings with collation C, > in turn, that is cheaper than sorting collation-aware strings > (probably more groups)? Within the group, we could keep the original > order of items. I think it's a fool's errand to even try to separate different sort column orderings by cost. We simply do not have sufficiently accurate cost information. The previous patch in this thread got reverted because of that (well, also some implementation issues, but mostly that), and nothing has happened to make me think that another try will fare any better. regards, tom lane