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 1rTOKZ-002YjW-Hc for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jan 2024 15:41:24 +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 1rTOKY-00HSOE-HK for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jan 2024 15:41:22 +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 1rTOKY-00HSO6-8K for pgsql-hackers@lists.postgresql.org; Fri, 26 Jan 2024 15:41:22 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rTOKV-003qRW-A0 for pgsql-hackers@lists.postgresql.org; Fri, 26 Jan 2024 15:41:21 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5100c4aa08cso514673e87.2 for ; Fri, 26 Jan 2024 07:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706283678; x=1706888478; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q8NR0WEYvy6jJrnEQYZYHhmGufYDzSU6+LZQjciPEqA=; b=HXSrPfjyVtLmDbfFHS8JVWiB2OR+887iL+ZAdsV7q8awg+KoTjbbBIwPC01D0AfW56 T9Y+PYQXhz6B58EnUm6VWauYuvw2F5eT9JOyXXHpwwy33N2N1HR84BTCnA01pQqWTcyY N4WusF3x9g/+ykKU4pYeXq2A/EpCyXQ3lqJhbkvBiy6Vz7+pi6Vu55qwxAnyeck0OV8F pOGFgpF1Y8GP235vDMSw+If9PUPXRxsZDt27Eree6QxRj3puFQeKyep1xUMsId5kLq4Y g4KkkDP4clmTGO/MqwcnEmisRqRSrzF6uOXgRC13svUN1on15poIQbKMXaVSQrU/7VcN 4psw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706283678; x=1706888478; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q8NR0WEYvy6jJrnEQYZYHhmGufYDzSU6+LZQjciPEqA=; b=YyEGPD3InAZ3xYkdL1byez/FBcibl/ymaroT1KqJivI/kzyRv6chwY/2RGOJ8CJYsV ZkwgvN6HTClSMcbuqHB6uE8eTtwBcf9tKLPY7Up5LTv6GhnwehbX2h5gWg0yBouWtAIc +qOugyqcjzsaK4kYR6/wCf3/b5BulnPeNmMnqo7XBmZcFeVAt0QMw3qCI0l6UfEB/yM2 8wsN/5p0uOkqwqTg90B+v63pFyIYJOclzxmstaYM9BgTRiREIMsq/9URmflVFmG0Z2hO bDFYety11anoTggptlPOATI1mv9W+ICspV/Gw86C0fAoytb/vJK7T/oB66HA3S+481kC GDBg== X-Gm-Message-State: AOJu0YwilkULLpkgEf1JALh3u58uMboPvTRTUn4gCnUS2tELHDPJxxk9 g9sJuS5LvyNPnJtlSg9cLiI5VHn+mw4/fGnUDMXaAvzVVWNWezkfGxnKn0PzWaClLl9L+VmAML8 iAehQoJz6t3flt0Yc8pUN0+f8zqY= X-Google-Smtp-Source: AGHT+IHk4XpQZTBFjOQpG5ddewm142z5Z3d9+WMhBKdnLrh5WOy5dMeBm/EBlNDHV+UIf0WIvfkFv1UC0HEsKlNfNZc= X-Received: by 2002:a19:700c:0:b0:510:a4c:342d with SMTP id h12-20020a19700c000000b005100a4c342dmr671339lfc.60.1706283678111; Fri, 26 Jan 2024 07:41:18 -0800 (PST) MIME-Version: 1.0 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> <2414422.1703647404@sss.pgh.pa.us> <783171.1706283503@sss.pgh.pa.us> In-Reply-To: <783171.1706283503@sss.pgh.pa.us> From: Robert Haas Date: Fri, 26 Jan 2024 10:41:05 -0500 Message-ID: Subject: Re: POC: GROUP BY optimization To: Tom Lane Cc: Alexander Korotkov , Andrei Lepikhov , PostgreSQL Developers , Tomas Vondra , Teodor Sigaev , David Rowley , "a.rybakina" , =?UTF-8?B?0JHQtdC70Y/Qu9C+0LIg0JTQsNC80LjRgCDQndCw0LjQu9C10LLQuNGH?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jan 26, 2024 at 10:38=E2=80=AFAM Tom Lane wrote= : > Sadly, that's not a small task: > > * We'd need to put effort into assigning more realistic procost > values --- preferably across the board, not just comparison functions. > As long as all the comparison functions have procost 1.0, you're > just flying blind. > > * As you mentioned, there'd need to be some accounting for the > likely size of varlena inputs, and especially whether they might > be toasted. > > * cost_sort knows nothing of the low-level sort algorithm improvements > we've made in recent years, such as abbreviated keys. > > That's a lot of work, and I think it has to be done before we try > to build infrastructure on top, not afterwards. OK, that makes sense to me. Thanks. --=20 Robert Haas EDB: http://www.enterprisedb.com