forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita8ccf4e

Richard Guo
Reordering DISTINCT keys to match input path's pathkeys
The ordering of DISTINCT items is semantically insignificant, so wecan reorder them as needed. In fact, in the parser, we absorb thesorting semantics of the sortClause as much as possible into thedistinctClause, ensuring that one clause is a prefix of the other.This can help avoid a possible need to re-sort.In this commit, we attempt to adjust the DISTINCT keys to match theinput path's pathkeys. This can likewise help avoid re-sorting, orallow us to use incremental-sort to save efforts.For DISTINCT ON expressions, the parser already ensures that theymatch the initial ORDER BY expressions. When reordering the DISTINCTkeys, we must ensure that the resulting pathkey list matches theinitial distinctClause pathkeys.This introduces a new GUC, enable_distinct_reordering, which allowsthe optimization to be disabled if needed.Author: Richard GuoReviewed-by: Andrei LepikhovDiscussion:https://postgr.es/m/CAMbWs48dR26cCcX0f=8bja2JKQPcU64136kHk=xekHT9xschiQ@mail.gmail.com1 parent5b8728c commita8ccf4e
File tree
11 files changed
+672
-201
lines changed- doc/src/sgml
- src
- backend
- optimizer
- path
- plan
- utils/misc
- include/optimizer
- test/regress
- expected
- sql
11 files changed
+672
-201
lines changedLines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5360 | 5360 |
| |
5361 | 5361 |
| |
5362 | 5362 |
| |
| 5363 | + | |
| 5364 | + | |
| 5365 | + | |
| 5366 | + | |
| 5367 | + | |
| 5368 | + | |
| 5369 | + | |
| 5370 | + | |
| 5371 | + | |
| 5372 | + | |
| 5373 | + | |
| 5374 | + | |
| 5375 | + | |
| 5376 | + | |
5363 | 5377 |
| |
5364 | 5378 |
| |
5365 | 5379 |
| |
|
Lines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2207 | 2207 |
| |
2208 | 2208 |
| |
2209 | 2209 |
| |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
2210 | 2245 |
| |
2211 | 2246 |
| |
2212 | 2247 |
| |
| |||
2240 | 2275 |
| |
2241 | 2276 |
| |
2242 | 2277 |
| |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
2243 | 2281 |
| |
2244 | 2282 |
| |
2245 | 2283 |
| |
|
0 commit comments
Comments
(0)