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 1sWFU0-00E3fE-L2 for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jul 2024 13:23:12 +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 1sWFTy-00Dbdj-OB for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jul 2024 13:23:11 +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 1sWFTy-00Dbda-9z for pgsql-hackers@lists.postgresql.org; Tue, 23 Jul 2024 13:23:10 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sWFTw-0013sx-DV for pgsql-hackers@postgresql.org; Tue, 23 Jul 2024 13:23:10 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2cb55418470so2751227a91.1 for ; Tue, 23 Jul 2024 06:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgguru-net.20230601.gappssmtp.com; s=20230601; t=1721740986; x=1722345786; darn=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=BxZm+xxcqMw+UPeq+iREhrYXAg7owcJgg6mNFxVAuYU=; b=bRkI9q7jkqom/I5V+zTF/iGAFON3DIH0hV394I69B8PddK33d8Q15MvGVZsi/hxtoz LsTtU2SXnYJjpjlJo1GvAKTd8KfzJomOk+vpk75F5T3JF31kUiscAGjXuCbM6hDtTu5g LtliFR15YWCLsIT/7vRJyNzrCarjjG0NoVshgZ8KR2UP2A3NBNZwWIn9+49a42e1pFvI svM20YhPctLBk7xjbWbrYZj4QsZ9QE47ZytbgczbVLObrLL9zf0M0vgTWXJxYxMmjrKy yC32Hg86bOPQ+heUPcD4YOeESYE1z0f4L004hVUadNqe/fGP7H5yzNN6pzskpR/MtD3z HZwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721740986; x=1722345786; 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=BxZm+xxcqMw+UPeq+iREhrYXAg7owcJgg6mNFxVAuYU=; b=V3kpazXB1PXxT0cVChXwJI9cwTl86ezW230Tr+/IRFyhQsVjFrGV3cEDJz+MeQI6OE +GusCSvSshdhja0zAkJk1V0AFPFwF5PfDyWi9e6eRFKZYS/VI28RNi3H7Yx5MJpv/8hH va3OfBioOhxsM+NKY7fVb+uh17tEAQc82orJS6n8bhGoKpKH7DYzvPSh4m3I5O1ceo10 YQLQhI86WzpayveBmcjEw7fT0yULpX5C3Vs+H1n6B8ycrj//Kk6VDTAMPB3Vd/frSbY9 90QAcJNRqe3RjFSr/geH1VMASSlXiIsp4DHTWdzVedz/h7ziZJuNR8qnI+ygL/iMxFdM XESg== X-Gm-Message-State: AOJu0Yx8Aqc6N2+PWrK69W7BfbfW5nbLGygJbuNY2fMBStmakWRYQv8U D4Z6vUpNRCcrMPUlO9jzgRkUjYpDKIt1MMa+reQVPg3dl8jPji5vW/JPbimkKBYYmsmfgy/VQQl VN9WpH6caG7OCkCVG2fO/5tqoqaZNzOVtbHhMMQ== X-Google-Smtp-Source: AGHT+IF2HqYmUwq0PsaSvFJ49CemIAZRtIYRvbRgotwg9oCg/AdinvmonyS5fujIHhN+KYUyUHtLZCEc4IBAIZCMExA= X-Received: by 2002:a17:90a:39c7:b0:2c9:ba2b:427b with SMTP id 98e67ed59e1d1-2cd15fe97c8mr6923569a91.41.1721740986272; Tue, 23 Jul 2024 06:23:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Christensen Date: Tue, 23 Jul 2024 08:22:55 -0500 Message-ID: Subject: Re: [PATCH] GROUP BY ALL To: "David G. Johnston" Cc: pgsql-hackers 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 Mon, Jul 22, 2024 at 4:34=E2=80=AFPM 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 feed= back. >> > > 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 wri= ter, not the reader. And furthermore usage of this is prone to be to the w= riter's detriment as well. I'd say this feature (at least for me) caters to the investigator; someone who is interactively looking at data hence why it would cater to the writer. Consider acquainting yourself with a large table that has a large number of annoying-named fields where you want to look at how different data is correlated or broken-down. Something along the lines of: SELECT last_name, substring(first_name,1,1) as first_initial, income_range, count(*) FROM census_data GROUP BY ALL; If you are iteratively looking at things, adding or removing fields from your breakdown, you only need to change it in a single place, the tlist. Additionally, expressions can be used transparently without needing to repeat them. (Yes, in practice, I'd often use GROUP BY 1, 2, say, but if you add more fields to this you need to edit in multiple places.) David