- Notifications
You must be signed in to change notification settings - Fork28
Commitd97b714
committed
Avoid using lcons and list_delete_first where it's easy to do so.
Formerly, lcons was about the same speed as lappend, but with the newList implementation, that's not so; with a long List, data movementimposes an O(N) cost on lcons and list_delete_first, but not lappend.Hence, invent list_delete_last with semantics parallel tolist_delete_first (but O(1) cost), and change various places to uselappend and list_delete_last where this can be done without muchviolence to the code logic.There are quite a few places that construct result lists using lcons notlappend. Some have semantic rationales for that; I added comments aboutit to a couple that didn't have them already. In many such places though,I think the coding is that way only because back in the dark ages lconswas faster than lappend. Hence, switch to lappend where this can be donewithout causing semantic changes.In ExecInitExprRec(), this results in aggregates and window functions thatare in the same plan node being executed in a different order than before.Generally, the executions of such functions ought to be independent ofeach other, so this shouldn't result in visibly different query results.But if you push it, as one regression test case does, you can show thatthe order is different. The new order seems saner; it's closer tothe order of the functions in the query text. And we never documentedor promised anything about this, anyway.Also, in gistfinishsplit(), don't bother building a reverse-order list;it's easy now to iterate backwards through the original list.It'd be possible to go further towards removing uses of lcons andlist_delete_first, but it'd require more extensive logic changes,and I'm not convinced it's worth it. Most of the remaining usesdeal with queues that probably never get long enough to be worthsweating over. (Actually, I doubt that any of the changes in thispatch will have measurable performance effects either. But betterto have good examples than bad ones in the code base.)Patch by me, thanks to David Rowley and Daniel Gustafsson for review.Discussion:https://postgr.es/m/21272.1563318411@sss.pgh.pa.us1 parentdfd0121 commitd97b714
File tree
15 files changed
+72
-47
lines changed- src
- backend
- access/gist
- catalog
- commands
- executor
- nodes
- optimizer/util
- parser
- rewrite
- utils/adt
- include/nodes
- test/regress/expected
15 files changed
+72
-47
lines changedLines changed: 5 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1323 | 1323 |
| |
1324 | 1324 |
| |
1325 | 1325 |
| |
1326 |
| - | |
1327 |
| - | |
1328 | 1326 |
| |
1329 | 1327 |
| |
1330 | 1328 |
| |
| |||
1339 | 1337 |
| |
1340 | 1338 |
| |
1341 | 1339 |
| |
1342 |
| - | |
1343 |
| - | |
1344 |
| - | |
1345 |
| - | |
1346 |
| - | |
1347 |
| - | |
1348 |
| - | |
1349 |
| - | |
1350 | 1340 |
| |
1351 | 1341 |
| |
1352 | 1342 |
| |
1353 | 1343 |
| |
1354 | 1344 |
| |
1355 | 1345 |
| |
1356 | 1346 |
| |
1357 |
| - | |
| 1347 | + | |
1358 | 1348 |
| |
1359 |
| - | |
1360 |
| - | |
| 1349 | + | |
| 1350 | + | |
1361 | 1351 |
| |
1362 | 1352 |
| |
1363 | 1353 |
| |
| |||
1371 | 1361 |
| |
1372 | 1362 |
| |
1373 | 1363 |
| |
1374 |
| - | |
1375 | 1364 |
| |
1376 | 1365 |
| |
1377 |
| - | |
1378 |
| - | |
| 1366 | + | |
| 1367 | + | |
1379 | 1368 |
| |
1380 | 1369 |
| |
1381 | 1370 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
633 | 633 |
| |
634 | 634 |
| |
635 | 635 |
| |
636 |
| - | |
| 636 | + | |
637 | 637 |
| |
638 | 638 |
| |
639 | 639 |
| |
| |||
653 | 653 |
| |
654 | 654 |
| |
655 | 655 |
| |
656 |
| - | |
| 656 | + | |
657 | 657 |
| |
658 | 658 |
| |
659 | 659 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1566 | 1566 |
| |
1567 | 1567 |
| |
1568 | 1568 |
| |
1569 |
| - | |
| 1569 | + | |
1570 | 1570 |
| |
1571 | 1571 |
| |
1572 | 1572 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
281 | 281 |
| |
282 | 282 |
| |
283 | 283 |
| |
284 |
| - | |
| 284 | + | |
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
288 |
| - | |
| 288 | + | |
289 | 289 |
| |
290 | 290 |
| |
291 | 291 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14480 | 14480 |
| |
14481 | 14481 |
| |
14482 | 14482 |
| |
| 14483 | + | |
| 14484 | + | |
| 14485 | + | |
| 14486 | + | |
| 14487 | + | |
14483 | 14488 |
| |
14484 | 14489 |
| |
14485 | 14490 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2999 | 2999 |
| |
3000 | 3000 |
| |
3001 | 3001 |
| |
3002 |
| - | |
| 3002 | + | |
3003 | 3003 |
| |
3004 | 3004 |
| |
3005 | 3005 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
786 | 786 |
| |
787 | 787 |
| |
788 | 788 |
| |
789 |
| - | |
| 789 | + | |
790 | 790 |
| |
791 | 791 |
| |
792 | 792 |
| |
| |||
834 | 834 |
| |
835 | 835 |
| |
836 | 836 |
| |
837 |
| - | |
| 837 | + | |
838 | 838 |
| |
839 | 839 |
| |
840 | 840 |
| |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
826 | 826 |
| |
827 | 827 |
| |
828 | 828 |
| |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
829 | 853 |
| |
830 | 854 |
| |
831 | 855 |
| |
|
Lines changed: 7 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
881 | 881 |
| |
882 | 882 |
| |
883 | 883 |
| |
884 |
| - | |
885 | 884 |
| |
886 |
| - | |
887 |
| - | |
888 |
| - | |
| 885 | + | |
| 886 | + | |
889 | 887 |
| |
890 | 888 |
| |
891 | 889 |
| |
| |||
1015 | 1013 |
| |
1016 | 1014 |
| |
1017 | 1015 |
| |
| 1016 | + | |
1018 | 1017 |
| |
1019 | 1018 |
| |
1020 | 1019 |
| |
| |||
4185 | 4184 |
| |
4186 | 4185 |
| |
4187 | 4186 |
| |
4188 |
| - | |
4189 |
| - | |
| 4187 | + | |
| 4188 | + | |
4190 | 4189 |
| |
4191 | 4190 |
| |
4192 | 4191 |
| |
| |||
4701 | 4700 |
| |
4702 | 4701 |
| |
4703 | 4702 |
| |
4704 |
| - | |
| 4703 | + | |
4705 | 4704 |
| |
4706 |
| - | |
| 4705 | + | |
4707 | 4706 |
| |
4708 | 4707 |
| |
4709 | 4708 |
| |
|
Lines changed: 10 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
419 | 419 |
| |
420 | 420 |
| |
421 | 421 |
| |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
422 | 429 |
| |
423 | 430 |
| |
424 | 431 |
| |
| |||
1339 | 1346 |
| |
1340 | 1347 |
| |
1341 | 1348 |
| |
1342 |
| - | |
| 1349 | + | |
1343 | 1350 |
| |
1344 | 1351 |
| |
1345 | 1352 |
| |
| |||
1351 | 1358 |
| |
1352 | 1359 |
| |
1353 | 1360 |
| |
1354 |
| - | |
| 1361 | + | |
1355 | 1362 |
| |
1356 | 1363 |
| |
1357 | 1364 |
| |
| |||
1363 | 1370 |
| |
1364 | 1371 |
| |
1365 | 1372 |
| |
1366 |
| - | |
| 1373 | + | |
1367 | 1374 |
| |
1368 | 1375 |
| |
1369 | 1376 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1132 | 1132 |
| |
1133 | 1133 |
| |
1134 | 1134 |
| |
1135 |
| - | |
| 1135 | + | |
1136 | 1136 |
| |
1137 | 1137 |
| |
1138 | 1138 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1973 | 1973 |
| |
1974 | 1974 |
| |
1975 | 1975 |
| |
1976 |
| - | |
| 1976 | + | |
1977 | 1977 |
| |
1978 | 1978 |
| |
1979 | 1979 |
| |
| |||
1986 | 1986 |
| |
1987 | 1987 |
| |
1988 | 1988 |
| |
1989 |
| - | |
| 1989 | + | |
1990 | 1990 |
| |
1991 | 1991 |
| |
1992 | 1992 |
| |
| |||
2059 | 2059 |
| |
2060 | 2060 |
| |
2061 | 2061 |
| |
2062 |
| - | |
| 2062 | + | |
2063 | 2063 |
| |
2064 | 2064 |
| |
2065 | 2065 |
| |
| |||
2084 | 2084 |
| |
2085 | 2085 |
| |
2086 | 2086 |
| |
2087 |
| - | |
| 2087 | + | |
2088 | 2088 |
| |
2089 | 2089 |
| |
2090 | 2090 |
| |
| |||
3711 | 3711 |
| |
3712 | 3712 |
| |
3713 | 3713 |
| |
3714 |
| - | |
| 3714 | + | |
3715 | 3715 |
| |
3716 | 3716 |
| |
3717 | 3717 |
| |
| |||
3722 | 3722 |
| |
3723 | 3723 |
| |
3724 | 3724 |
| |
3725 |
| - | |
| 3725 | + | |
3726 | 3726 |
| |
3727 | 3727 |
| |
3728 | 3728 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3201 | 3201 |
| |
3202 | 3202 |
| |
3203 | 3203 |
| |
3204 |
| - | |
| 3204 | + | |
3205 | 3205 |
| |
3206 | 3206 |
| |
3207 | 3207 |
| |
3208 | 3208 |
| |
3209 | 3209 |
| |
3210 | 3210 |
| |
3211 | 3211 |
| |
3212 |
| - | |
| 3212 | + | |
3213 | 3213 |
| |
3214 | 3214 |
| |
3215 | 3215 |
| |
3216 | 3216 |
| |
3217 |
| - | |
| 3217 | + | |
3218 | 3218 |
| |
3219 | 3219 |
| |
3220 | 3220 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
531 | 531 |
| |
532 | 532 |
| |
533 | 533 |
| |
| 534 | + | |
534 | 535 |
| |
535 | 536 |
| |
536 | 537 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2030 | 2030 |
| |
2031 | 2031 |
| |
2032 | 2032 |
| |
2033 |
| - | |
2034 | 2033 |
| |
2035 |
| - | |
| 2034 | + | |
2036 | 2035 |
| |
| 2036 | + | |
2037 | 2037 |
| |
2038 | 2038 |
| |
2039 | 2039 |
| |
|
0 commit comments
Comments
(0)