forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit14231a4
committed
Avoid creation of useless EquivalenceClasses during planning.
Zoltan Boszormenyi exhibited a test case in which planning time wasdominated by construction of EquivalenceClasses and PathKeys that had noactual relevance to the query (and in fact got discarded immediately).This happened because we generated PathKeys describing the sort ordering ofevery index on every table in the query, and only after that checked to seeif the sort ordering was relevant. The EC/PK construction code is O(N^2)in the number of ECs, which is all right for the intended number of suchobjects, but it gets out of hand if there are ECs for lots of irrelevantindexes.To fix, twiddle the handling of mergeclauses a little bit to ensure thatevery interesting EC is created before we begin path generation. (Thisdoesn't cost anything --- in fact I think it's a bit cheaper than before--- since we always eventually created those ECs anyway.) Then, if anindex column can't be found in any pre-existing EC, we know that that sortordering is irrelevant for the query. Instead of creating a useless EC,we can just not build a pathkey for the index column in the first place.The index will still be considered if it's useful for non-order-relatedreasons, but we will think of its output as unsorted.1 parentf184de3 commit14231a4
File tree
6 files changed
+220
-62
lines changed- src
- backend/optimizer
- path
- plan
- include/optimizer
6 files changed
+220
-62
lines changedLines changed: 33 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
632 | 632 |
| |
633 | 633 |
| |
634 | 634 |
| |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
635 | 668 |
| |
636 |
| - | |
637 |
| - | |
638 |
| - | |
639 | 669 |
| |
640 | 670 |
|
Lines changed: 38 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 |
| |
82 | 86 |
| |
83 | 87 |
| |
| |||
106 | 110 |
| |
107 | 111 |
| |
108 | 112 |
| |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
109 | 117 |
| |
110 | 118 |
| |
111 | 119 |
| |
| |||
236 | 244 |
| |
237 | 245 |
| |
238 | 246 |
| |
| 247 | + | |
| 248 | + | |
| 249 | + | |
239 | 250 |
| |
240 |
| - | |
241 | 251 |
| |
242 | 252 |
| |
243 | 253 |
| |
| |||
266 | 276 |
| |
267 | 277 |
| |
268 | 278 |
| |
| 279 | + | |
| 280 | + | |
| 281 | + | |
269 | 282 |
| |
270 | 283 |
| |
271 | 284 |
| |
| |||
276 | 289 |
| |
277 | 290 |
| |
278 | 291 |
| |
| 292 | + | |
| 293 | + | |
| 294 | + | |
279 | 295 |
| |
280 | 296 |
| |
281 | 297 |
| |
| |||
286 | 302 |
| |
287 | 303 |
| |
288 | 304 |
| |
| 305 | + | |
| 306 | + | |
| 307 | + | |
289 | 308 |
| |
290 | 309 |
| |
291 | 310 |
| |
| |||
311 | 330 |
| |
312 | 331 |
| |
313 | 332 |
| |
| 333 | + | |
| 334 | + | |
| 335 | + | |
314 | 336 |
| |
315 | 337 |
| |
316 | 338 |
| |
| |||
362 | 384 |
| |
363 | 385 |
| |
364 | 386 |
| |
365 |
| - | |
| 387 | + | |
366 | 388 |
| |
367 | 389 |
| |
368 | 390 |
| |
369 | 391 |
| |
370 | 392 |
| |
| 393 | + | |
| 394 | + | |
| 395 | + | |
371 | 396 |
| |
372 | 397 |
| |
373 |
| - | |
| 398 | + | |
| 399 | + | |
374 | 400 |
| |
375 | 401 |
| |
376 | 402 |
| |
| |||
382 | 408 |
| |
383 | 409 |
| |
384 | 410 |
| |
385 |
| - | |
| 411 | + | |
| 412 | + | |
386 | 413 |
| |
387 | 414 |
| |
388 | 415 |
| |
| |||
426 | 453 |
| |
427 | 454 |
| |
428 | 455 |
| |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
429 | 460 |
| |
430 |
| - | |
| 461 | + | |
431 | 462 |
| |
432 | 463 |
| |
433 | 464 |
| |
| |||
1094 | 1125 |
| |
1095 | 1126 |
| |
1096 | 1127 |
| |
1097 |
| - | |
1098 |
| - | |
| 1128 | + | |
| 1129 | + | |
1099 | 1130 |
| |
1100 | 1131 |
| |
1101 | 1132 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1041 | 1041 |
| |
1042 | 1042 |
| |
1043 | 1043 |
| |
1044 |
| - | |
| 1044 | + | |
1045 | 1045 |
| |
1046 | 1046 |
| |
1047 | 1047 |
| |
|
0 commit comments
Comments
(0)