forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbe3b265
committed
Improve SELECT DISTINCT to consider hash aggregation, as well as sort/uniq,
as methods for implementing the DISTINCT step. This eliminates the formerperformance gap between DISTINCT and GROUP BY, and also makes it possibleto do SELECT DISTINCT on datatypes that only support hashing not sorting.SELECT DISTINCT ON is still always implemented by sorting; it would takeexecutor changes to support hashing that, and it's not clear it's worththe trouble.This is a release-note-worthy incompatibility from previous PG versions,since SELECT DISTINCT can no longer be counted on to deliver sorted outputwithout explicitly saying ORDER BY. (Anyone who can't cope with thatcan consider turning off enable_hashagg.)Several regression test queries needed to have ORDER BY added to preservestable output order. I fixed the ones that manifested here, but theremight be some other cases that show up on other platforms.1 parent4abd7b4 commitbe3b265
File tree
13 files changed
+396
-111
lines changed- src
- backend
- nodes
- optimizer/plan
- parser
- include/nodes
- test/regress
- expected
- input
- output
- sql
13 files changed
+396
-111
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
1334 | 1334 |
| |
1335 | 1335 |
| |
1336 | 1336 |
| |
| 1337 | + | |
1337 | 1338 |
| |
1338 | 1339 |
| |
1339 | 1340 |
| |
|
Lines changed: 13 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
| 17 | + | |
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| |||
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
69 |
| - | |
70 |
| - | |
71 |
| - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
| 123 | + | |
| 124 | + | |
123 | 125 |
| |
124 | 126 |
| |
125 | 127 |
| |
| |||
237 | 239 |
| |
238 | 240 |
| |
239 | 241 |
| |
240 |
| - | |
| 242 | + | |
| 243 | + | |
241 | 244 |
| |
242 | 245 |
| |
243 | 246 |
| |
| 247 | + | |
244 | 248 |
| |
245 | 249 |
| |
246 | 250 |
| |
| |||
286 | 290 |
| |
287 | 291 |
| |
288 | 292 |
| |
289 |
| - | |
| 293 | + | |
| 294 | + | |
290 | 295 |
| |
291 |
| - | |
| 296 | + | |
| 297 | + | |
292 | 298 |
| |
293 | 299 |
| |
294 | 300 |
| |
|
0 commit comments
Comments
(0)