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 1sW0nN-00Clrg-EQ for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jul 2024 21:42:13 +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 1sW0mN-007EAa-Ix for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jul 2024 21:41:11 +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 1sW0mN-007E9h-5A for pgsql-hackers@lists.postgresql.org; Mon, 22 Jul 2024 21:41:11 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sW0mK-000vZn-UI for pgsql-hackers@postgresql.org; Mon, 22 Jul 2024 21:41:10 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-70d2b27c115so983737b3a.2 for ; Mon, 22 Jul 2024 14:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721684468; x=1722289268; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ANjReYp5ozwCVaZtgLl49SD3zvWggkzvtPZ2aWSx0vI=; b=YVuh9zjEXTAJXC665cD2OUof7/doPnXtkcnMC568u6j32F1M7npym+u+ZVE+/LxQEO wZpUDelUi4dXXQ1SG8j7/8UfbDi5WoLyLSfF+gsuz2MNJAJYoEXcVEPnSS4QqKkSa+va 9zN3jf2ixq4j6HvMRtnR+dcJysbvA/4ssF0B/oQwJrGAjE7LwHv9W30L9A2rkePqLAjJ B6NcZXosvnnMXgcHyR48H/5XEFJPpcg2kXBjdM3LSyW0aS//i5ylgDy5nz1sPOdZwY7n 78XaP6Ics76rin2Sq1FybF6YmP9hdZHVV1mDaEPI0JYGOcGfrIO/ZbnJG+Bsg8mXvpTs S4IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721684468; x=1722289268; h=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=ANjReYp5ozwCVaZtgLl49SD3zvWggkzvtPZ2aWSx0vI=; b=cEfE/m02L9zrwsx5vSY8wH1ZL4d/uZu3ilulPn90eVG00kzl14kpbNfpyp/CcIqAzs eNTkeegHXYgUKMEaIFA0Nu1Kxd7S2SXVJm3M5YfUOfWqtewbrlhL7/LK0giXUySuU/OL g/32w9xBLiSmgJNVCVMj7PJMSL//pFqTo0bSJNA1GCjJCPIuFEmt1L0hQyV6YIEzeFcA 5yuTHK5SmWHij52dZ5Ix/nZz9SGyEIba7cnjlXxCzE3wtLoYUzcYTLu2qs0OH/8SEz+B 2OlXQbzzAjhI/M0WjvXnaX9ayP/gBOHOWx0xxdHun3GvQ1aj2ZT1hTvpOfbhr4FZ75HE Q8jQ== X-Forwarded-Encrypted: i=1; AJvYcCWfxmRThvhdOVBpTf2skgXSlNk8f7lXgvnMtRw8PJcFmHGKG/65k7ZRYISD+FE8ptcLufRzlKLAY1H713h3IAqBnPAY0ISHXS5eiDYp X-Gm-Message-State: AOJu0Yw1LSYQ0gX3X7LmSDR0ptoiWGAMsAsV/81TyeJEehoWHUmsZdg1 RgolcLd+45m1xA9aXL33SX4ld4Q5Cc3YkkHE/eOAz7M/HouUtxATnQOuPFQkw6NPSljD3Iet2z/ EwNzqJil1ZZMGiJJ12oaTa/LfPe8= X-Google-Smtp-Source: AGHT+IGMx98VsO/0wZA/mvANBvVkZ2GyB5xinkCUvOht7zkwP1rW2X1WtlfoGitq+JNxStfYGwkrubgM4ax2PSYBBeI= X-Received: by 2002:a05:6a00:114c:b0:706:6b0b:9573 with SMTP id d2e1a72fcca58-70d0eff151bmr9857736b3a.19.1721684467924; Mon, 22 Jul 2024 14:41:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Isaac Morland Date: Mon, 22 Jul 2024 17:40:55 -0400 Message-ID: Subject: Re: [PATCH] GROUP BY ALL To: "David G. Johnston" Cc: David Christensen , pgsql-hackers Content-Type: multipart/alternative; boundary="000000000000204b94061ddce727" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000204b94061ddce727 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 22 Jul 2024 at 17:34, David G. Johnston wrote: > On Mon, Jul 22, 2024 at 1:55=E2=80=AFPM David Christensen > wrote: > >> I see that there'd been some chatter but not a lot of discussion about >> a GROUP BY ALL feature/functionality. There certainly is utility in >> such a construct IMHO. >> >> Still need some docs; just throwing this out there and getting some >> feedback. >> >> > I strongly dislike adding this feature. I'd only consider supporting it > if it was part of the SQL standard. > > Code is written once and read many times. This feature caters to > the writer, not the reader. And furthermore usage of this is prone to be > to the writer's detriment as well. > And for when this might be useful, the syntax for it already exists, although a spurious error message is generated: odyssey=3D> select (uw_term).*, count(*) from uw_term group by uw_term; ERROR: column "uw_term.term_id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: select (uw_term).*, count(*) from uw_term group by uw_term; ^ I'm not sure exactly what's going on here =E2=80=94 it's like it's still se= eing the table name in the field list as only a table name and not the value corresponding to the whole table as a row value (But in general I'm not happy with the system's ability to figure out that a column's value has only one possibility given the grouping columns). You can work around: odyssey=3D> with t as (select uw_term, count(*) from uw_term group by uw_term) select (uw_term).*, count from t; This query works. --000000000000204b94061ddce727 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, 22 Jul 2024 at 17:34, David G. Jo= hnston <david.g.johnston@g= mail.com> wrote:
On Mo= n, Jul 22, 2024 at 1:55=E2=80=AFPM David Christensen <david@pgguru.net> wrote:<= br>
I see that there= 'd been some chatter but not a lot of discussion about
a GROUP BY ALL feature/functionality.=C2=A0 There certainly is utility in such a construct IMHO.

Still need some docs; just throwing this out there and getting some feedbac= k.


I strongly dislike adding this feature.=C2=A0 I'd only= consider supporting it if it was part of the SQL standard.

Code is written once and read many=C2=A0ti= mes.=C2=A0 This feature caters to the=C2=A0writer, not the=C2=A0reader.=C2= =A0 And furthermore usage of this is prone to be to the writer's detrim= ent as well.

And for when= this might be useful, the syntax for it already exists, although a spuriou= s error message is generated:

odyssey=3D> selec= t (uw_term).*, count(*) from uw_term group by uw_term;
ERROR: =C2=A0colu= mn "uw_term.term_id" must appear in the GROUP BY clause or be use= d in an aggregate function
LINE 1: select (uw_term).*, count(*) from uw_= term group by uw_term;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ^

I'm not sure exactly what's g= oing on here =E2=80=94 it's like it's still seeing the table name i= n the field list as only a table name and not the value corresponding to th= e whole table as a row value (But in general I'm not happy with the sys= tem's ability to figure out that a column's value has only one poss= ibility given the grouping columns). You can work around:

odyssey=3D> with t as (select uw_term, count(*) from uw_term gro= up by uw_term) select (uw_term).*, count from t;

This query works.
--000000000000204b94061ddce727--