forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4cc832f
committed
Tidy up code in get_cheapest_group_keys_order()
There are a few things that we could do a little better withinget_cheapest_group_keys_order():1. We should be using list_free() rather than pfree() on a List.2. We should use for_each_from() instead of manually coding a for loop toskip the first n elements of a List3. list_truncate(list_copy(...), n) is not a great way to copy the first nelements of a list. Let's invent list_copy_head() for that. That way wedon't need to copy the entire list just to truncate it directlyafterwards.4. We can simplify finding the cheapest cost by setting the cheapest costvariable to DBL_MAX. That allows us to skip special-casing the initialiteration of the loop.Author: David RowleyDiscussion:https://postgr.es/m/CAApHDvrGyL3ft8waEkncG9y5HDMu5TFFJB1paoTC8zi9YK97Nw@mail.gmail.comBackpatch-through: 15, where get_cheapest_group_keys_order was added.1 parent83f1c7b commit4cc832f
File tree
3 files changed
+40
-16
lines changed- src
- backend
- nodes
- optimizer/path
- include/nodes
3 files changed
+40
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1584 | 1584 | | |
1585 | 1585 | | |
1586 | 1586 | | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
1587 | 1608 | | |
1588 | 1609 | | |
1589 | 1610 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
591 | 593 | | |
592 | 594 | | |
593 | 595 | | |
594 | | - | |
| 596 | + | |
595 | 597 | | |
596 | 598 | | |
597 | 599 | | |
| |||
620 | 622 | | |
621 | 623 | | |
622 | 624 | | |
623 | | - | |
624 | 625 | | |
| 626 | + | |
625 | 627 | | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
631 | 633 | | |
632 | | - | |
633 | | - | |
634 | | - | |
| 634 | + | |
| 635 | + | |
635 | 636 | | |
636 | | - | |
637 | | - | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
638 | 640 | | |
639 | | - | |
| 641 | + | |
640 | 642 | | |
641 | 643 | | |
642 | 644 | | |
| |||
646 | 648 | | |
647 | 649 | | |
648 | 650 | | |
649 | | - | |
| 651 | + | |
650 | 652 | | |
651 | | - | |
| 653 | + | |
652 | 654 | | |
653 | 655 | | |
654 | 656 | | |
| |||
689 | 691 | | |
690 | 692 | | |
691 | 693 | | |
692 | | - | |
| 694 | + | |
693 | 695 | | |
694 | 696 | | |
695 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
| 623 | + | |
623 | 624 | | |
624 | 625 | | |
625 | 626 | | |
| |||
0 commit comments
Comments
(0)