Re: Removing redundant grouping columns
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2022-12-30T21:02:06Z
Lists: pgsql-hackers
Attachments
- v3-0001-remove-redundant-GROUP-BY.patch (text/x-diff) patch v3-0001
- v3-0002-remove-redundant-DISTINCT.patch (text/x-diff) patch v3-0002
I wrote: > Richard Guo <guofenglinux@gmail.com> writes: >> While we are here, I wonder if we can do the same trick for >> distinctClause, to cope with cases like >> select distinct a.x, b.y from a, b where a.x = b.y; > We do that already, no? Oh, wait, I see what you mean: we are smart in code paths that rely on distinct_pathkeys, but not in the hash-based code paths. Right, that can be fixed the same way. 0001 attached is the same as before, 0002 adds similar logic for the distinctClause. The plan change in expected/pg_trgm.out is surprising at first glance, but I believe it's correct: the item that is being dropped is a parameterless STABLE function, so its value is not supposed to change for the duration of the scan. regards, tom lane
Commits
-
Remove redundant grouping and DISTINCT columns.
- 8d83a5d0a267 16.0 landed
-
Add 250c8ee07ed to git-blame-ignore-revs
- ff23b592ad66 16.0 cited