Re: POC: GROUP BY optimization

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Richard Guo <guofenglinux(at)gmail(dot)com>, Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, David Rowley <dgrowleyml(at)gmail(dot)com>, "a(dot)rybakina" <a(dot)rybakina(at)postgrespro(dot)ru>
Subject: Re: POC: GROUP BY optimization
Date: 2024-04-24 11:17:34
Message-ID: CACJufxGnxC1XGCvPreogU8jcZyEfbMisDCP25+hB7hYP4L=RKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi
one more question (maybe a dumb one....)

drop table if exists t1;
CREATE TABLE t1 AS
SELECT (i % 10)::numeric AS x,(i % 10)::int8 AS y,'abc' || i % 10 AS
z, i::int4 AS w
FROM generate_series(1, 100) AS i;
CREATE INDEX t1_x_y_idx ON t1 (x, y);
ANALYZE t1;
SET enable_hashagg = off;
SET enable_seqscan = off;

EXPLAIN (COSTS OFF, verbose) SELECT count(*) FROM t1 GROUP BY z,x,y,w
order by w;

QUERY PLAN
------------------------------------------------------
GroupAggregate
Output: count(*), w, z, x, y
Group Key: t1.w, t1.x, t1.y, t1.z
-> Sort
Output: w, z, x, y
Sort Key: t1.w, t1.x, t1.y, t1.z
-> Index Scan using t1_x_y_idx on public.t1
Output: w, z, x, y
(8 rows)

if you do
` Sort Key: t1.w, t1.x, t1.y, t1.z`

then the output is supposed to be:

Output: w, x, y, z

?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2024-04-24 11:31:12 Re: Cutting support for OpenSSL 1.0.1 and 1.0.2 in 17~?
Previous Message Hans Buschmann 2024-04-24 11:02:18 Proposal: Early providing of PGDG repositories for the major Linux distributions like Fedora or Debian