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

Richard Guo
Consider explicit incremental sort for mergejoins
For a mergejoin, if the given outer path or inner path is not alreadywell enough ordered, we need to do an explicit sort. Currently, weonly consider explicit full sort and do not account for incrementalsort.In this patch, for the outer path of a mergejoin, we choose to useexplicit incremental sort if it is enabled and there are presortedkeys. For the inner path, though, we cannot use incremental sortbecause it does not support mark/restore at present.The rationale is based on the assumption that incremental sort isalways faster than full sort when there are presorted keys, a premisethat has been applied in various parts of the code. In addition, thecurrent cost model tends to favor incremental sort as being cheaperthan full sort in the presence of presorted keys, making it reasonablenot to consider full sort in such cases.It could be argued that what if a mergejoin with an incremental sortas the outer path is selected as the inner path of another mergejoin.However, this should not be a problem, because mergejoin itself doesnot support mark/restore either, and we will add a Material node ontop of it anyway in this case (see final_cost_mergejoin).There is one ensuing plan change in the regression tests, and we haveto modify that test case to ensure that it continues to test what itis intended to.No backpatch as this could result in plan changes.Author: Richard GuoReviewed-by: David Rowley, Tomas VondraDiscussion:https://postgr.es/m/CAMbWs49x425QrX7h=Ux05WEnt8GS757H-jOP3_xsX5t1FoUsZw@mail.gmail.com1 parentc4528fd commit828e94c
File tree
6 files changed
+184
-41
lines changed- src
- backend/optimizer
- path
- plan
- test/regress
- expected
- sql
6 files changed
+184
-41
lines changedLines changed: 57 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3532 | 3532 |
| |
3533 | 3533 |
| |
3534 | 3534 |
| |
3535 |
| - | |
| 3535 | + | |
| 3536 | + | |
3536 | 3537 |
| |
3537 | 3538 |
| |
3538 | 3539 |
| |
| |||
3569 | 3570 |
| |
3570 | 3571 |
| |
3571 | 3572 |
| |
3572 |
| - | |
| 3573 | + | |
| 3574 | + | |
3573 | 3575 |
| |
3574 | 3576 |
| |
3575 | 3577 |
| |
| |||
3682 | 3684 |
| |
3683 | 3685 |
| |
3684 | 3686 |
| |
3685 |
| - | |
3686 |
| - | |
3687 |
| - | |
3688 |
| - | |
3689 |
| - | |
3690 |
| - | |
3691 |
| - | |
3692 |
| - | |
3693 |
| - | |
3694 |
| - | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
3695 | 3735 |
| |
3696 | 3736 |
| |
3697 | 3737 |
| |
| |||
3711 | 3751 |
| |
3712 | 3752 |
| |
3713 | 3753 |
| |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
3714 | 3759 |
| |
3715 | 3760 |
| |
3716 | 3761 |
| |
|
Lines changed: 81 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
179 | 179 |
| |
180 | 180 |
| |
181 | 181 |
| |
| 182 | + | |
| 183 | + | |
182 | 184 |
| |
183 | 185 |
| |
184 | 186 |
| |
| |||
4523 | 4525 |
| |
4524 | 4526 |
| |
4525 | 4527 |
| |
4526 |
| - | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
4527 | 4562 |
| |
4528 |
| - | |
| 4563 | + | |
| 4564 | + | |
4529 | 4565 |
| |
4530 |
| - | |
4531 |
| - | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
4532 | 4573 |
| |
4533 | 4574 |
| |
4534 | 4575 |
| |
4535 | 4576 |
| |
4536 | 4577 |
| |
4537 | 4578 |
| |
4538 | 4579 |
| |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
4539 | 4585 |
| |
4540 | 4586 |
| |
4541 | 4587 |
| |
| |||
5447 | 5493 |
| |
5448 | 5494 |
| |
5449 | 5495 |
| |
5450 |
| - | |
5451 |
| - | |
5452 |
| - | |
5453 |
| - | |
5454 | 5496 |
| |
5455 | 5497 |
| |
5456 | 5498 |
| |
| |||
5469 | 5511 |
| |
5470 | 5512 |
| |
5471 | 5513 |
| |
| 5514 | + | |
| 5515 | + | |
| 5516 | + | |
| 5517 | + | |
| 5518 | + | |
| 5519 | + | |
| 5520 | + | |
| 5521 | + | |
| 5522 | + | |
| 5523 | + | |
| 5524 | + | |
| 5525 | + | |
| 5526 | + | |
| 5527 | + | |
| 5528 | + | |
| 5529 | + | |
| 5530 | + | |
| 5531 | + | |
| 5532 | + | |
| 5533 | + | |
| 5534 | + | |
| 5535 | + | |
| 5536 | + | |
| 5537 | + | |
| 5538 | + | |
| 5539 | + | |
| 5540 | + | |
| 5541 | + | |
| 5542 | + | |
| 5543 | + | |
| 5544 | + | |
5472 | 5545 |
| |
5473 | 5546 |
| |
5474 | 5547 |
| |
|
Lines changed: 16 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2858 | 2858 |
| |
2859 | 2859 |
| |
2860 | 2860 |
| |
2861 |
| - | |
| 2861 | + | |
2862 | 2862 |
| |
2863 | 2863 |
| |
2864 | 2864 |
| |
2865 | 2865 |
| |
2866 |
| - | |
2867 |
| - | |
2868 |
| - | |
2869 |
| - | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
2870 | 2870 |
| |
2871 |
| - | |
2872 |
| - | |
2873 |
| - | |
2874 |
| - | |
2875 |
| - | |
2876 |
| - | |
2877 |
| - | |
2878 |
| - | |
2879 |
| - | |
2880 |
| - | |
2881 |
| - | |
2882 |
| - | |
2883 |
| - | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
2884 | 2882 |
| |
2885 | 2883 |
| |
2886 | 2884 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1701 | 1701 |
| |
1702 | 1702 |
| |
1703 | 1703 |
| |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + |
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1232 | 1232 |
| |
1233 | 1233 |
| |
1234 | 1234 |
| |
1235 |
| - | |
| 1235 | + | |
1236 | 1236 |
| |
1237 | 1237 |
| |
1238 | 1238 |
| |
1239 | 1239 |
| |
1240 |
| - | |
1241 |
| - | |
| 1240 | + | |
| 1241 | + | |
1242 | 1242 |
| |
1243 | 1243 |
| |
1244 | 1244 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + |
0 commit comments
Comments
(0)