- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitb8d7f05
committed
Faster expression evaluation and targetlist projection.
This replaces the old, recursive tree-walk based evaluation, withnon-recursive, opcode dispatch based, expression evaluation.Projection is now implemented as part of expression evaluation.This both leads to significant performance improvements, and makesfuture just-in-time compilation of expressions easier.The speed gains primarily come from:- non-recursive implementation reduces stack usage / overhead- simple sub-expressions are implemented with a single jump, without function calls- sharing some state between different sub-expressions- reduced amount of indirect/hard to predict memory accesses by laying out operation metadata sequentially; including the avoidance of nearly all of the previously used linked lists- more code has been moved to expression initialization, avoiding constant re-checks at evaluation timeFuture just-in-time compilation (JIT) has become easier, asdemonstrated by released patches intended to be merged in a laterrelease, for primarily two reasons: Firstly, due to a stricter splitbetween expression initialization and evaluation, less code has to behandled by the JIT. Secondly, due to the non-recursive nature of thegenerated "instructions", less performance-critical code-paths caneasily be shared between interpreted and compiled evaluation.The new framework allows for significant future optimizations. E.g.:- basic infrastructure for to later reduce the per executor-startup overhead of expression evaluation, by caching state in prepared statements. That'd be helpful in OLTPish scenarios where initialization overhead is measurable.- optimizing the generated "code". A number of proposals for potential work has already been made.- optimizing the interpreter. Similarly a number of proposals have been made here too.The move of logic into the expression initialization step leads to somebackward-incompatible changes:- Function permission checks are now done during expression initialization, whereas previously they were done during execution. In edge cases this can lead to errors being raised that previously wouldn't have been, e.g. a NULL array being coerced to a different array type previously didn't perform checks.- The set of domain constraints to be checked, is now evaluated once during expression initialization, previously it was re-built every time a domain check was evaluated. For normal queries this doesn't change much, but e.g. for plpgsql functions, which caches ExprStates, the old set could stick around longer. The behavior around might still change.Author: Andres Freund, with significant changes by Tom Lane,changes by Heikki LinnakangasReviewed-By: Tom Lane, Heikki LinnakangasDiscussion:https://postgr.es/m/20161206034955.bh33paeralxbtluv@alap3.anarazel.de1 parent7d3957e commitb8d7f05
File tree
71 files changed
+8871
-6534
lines changed- contrib/postgres_fdw
- src
- backend
- bootstrap
- catalog
- commands
- executor
- optimizer
- path
- plan
- util
- utils
- adt
- cache
- include
- executor
- nodes
- utils
- pl/plpgsql/src
- test/regress
- expected
- sql
- tools/pgindent
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
71 files changed
+8871
-6534
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3421 | 3421 |
| |
3422 | 3422 |
| |
3423 | 3423 |
| |
3424 |
| - | |
| 3424 | + | |
3425 | 3425 |
| |
3426 | 3426 |
| |
3427 | 3427 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1084 | 1084 |
| |
1085 | 1085 |
| |
1086 | 1086 |
| |
1087 |
| - | |
| 1087 | + | |
1088 | 1088 |
| |
1089 | 1089 |
| |
1090 | 1090 |
| |
|
Lines changed: 18 additions & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1658 | 1658 |
| |
1659 | 1659 |
| |
1660 | 1660 |
| |
1661 |
| - | |
| 1661 | + | |
1662 | 1662 |
| |
1663 | 1663 |
| |
1664 | 1664 |
| |
| |||
1774 | 1774 |
| |
1775 | 1775 |
| |
1776 | 1776 |
| |
1777 |
| - | |
1778 |
| - | |
1779 |
| - | |
| 1777 | + | |
| 1778 | + | |
1780 | 1779 |
| |
1781 | 1780 |
| |
1782 | 1781 |
| |
| |||
2208 | 2207 |
| |
2209 | 2208 |
| |
2210 | 2209 |
| |
2211 |
| - | |
| 2210 | + | |
2212 | 2211 |
| |
2213 | 2212 |
| |
2214 | 2213 |
| |
| |||
2247 | 2246 |
| |
2248 | 2247 |
| |
2249 | 2248 |
| |
2250 |
| - | |
2251 |
| - | |
2252 |
| - | |
| 2249 | + | |
2253 | 2250 |
| |
2254 | 2251 |
| |
2255 | 2252 |
| |
| |||
2552 | 2549 |
| |
2553 | 2550 |
| |
2554 | 2551 |
| |
2555 |
| - | |
| 2552 | + | |
2556 | 2553 |
| |
2557 |
| - | |
| 2554 | + | |
2558 | 2555 |
| |
2559 | 2556 |
| |
2560 | 2557 |
| |
| |||
2619 | 2616 |
| |
2620 | 2617 |
| |
2621 | 2618 |
| |
2622 |
| - | |
| 2619 | + | |
2623 | 2620 |
| |
2624 | 2621 |
| |
2625 | 2622 |
| |
| |||
2646 | 2643 |
| |
2647 | 2644 |
| |
2648 | 2645 |
| |
2649 |
| - | |
| 2646 | + | |
2650 | 2647 |
| |
2651 | 2648 |
| |
2652 | 2649 |
| |
| |||
2672 | 2669 |
| |
2673 | 2670 |
| |
2674 | 2671 |
| |
2675 |
| - | |
2676 |
| - | |
2677 |
| - | |
| 2672 | + | |
2678 | 2673 |
| |
2679 | 2674 |
| |
2680 | 2675 |
| |
| |||
2699 | 2694 |
| |
2700 | 2695 |
| |
2701 | 2696 |
| |
2702 |
| - | |
| 2697 | + | |
2703 | 2698 |
| |
2704 |
| - | |
| 2699 | + | |
2705 | 2700 |
| |
2706 | 2701 |
| |
2707 | 2702 |
| |
| |||
2732 | 2727 |
| |
2733 | 2728 |
| |
2734 | 2729 |
| |
2735 |
| - | |
| 2730 | + | |
2736 | 2731 |
| |
2737 | 2732 |
| |
2738 | 2733 |
| |
| |||
2962 | 2957 |
| |
2963 | 2958 |
| |
2964 | 2959 |
| |
2965 |
| - | |
| 2960 | + | |
2966 | 2961 |
| |
2967 | 2962 |
| |
2968 | 2963 |
| |
| |||
2992 | 2987 |
| |
2993 | 2988 |
| |
2994 | 2989 |
| |
2995 |
| - | |
2996 |
| - | |
2997 |
| - | |
| 2990 | + | |
2998 | 2991 |
| |
2999 | 2992 |
| |
3000 | 2993 |
| |
| |||
3121 | 3114 |
| |
3122 | 3115 |
| |
3123 | 3116 |
| |
3124 |
| - | |
| 3117 | + | |
3125 | 3118 |
| |
3126 |
| - | |
| 3119 | + | |
3127 | 3120 |
| |
3128 | 3121 |
| |
3129 | 3122 |
| |
| |||
3177 | 3170 |
| |
3178 | 3171 |
| |
3179 | 3172 |
| |
3180 |
| - | |
| 3173 | + | |
3181 | 3174 |
| |
3182 | 3175 |
| |
3183 | 3176 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1618 | 1618 |
| |
1619 | 1619 |
| |
1620 | 1620 |
| |
1621 |
| - | |
1622 |
| - | |
| 1621 | + | |
1623 | 1622 |
| |
1624 | 1623 |
| |
1625 | 1624 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
307 | 307 |
| |
308 | 308 |
| |
309 | 309 |
| |
310 |
| - | |
| 310 | + | |
311 | 311 |
| |
312 | 312 |
| |
313 | 313 |
| |
|
Lines changed: 4 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
713 | 713 |
| |
714 | 714 |
| |
715 | 715 |
| |
716 |
| - | |
| 716 | + | |
717 | 717 |
| |
718 | 718 |
| |
719 | 719 |
| |
| |||
739 | 739 |
| |
740 | 740 |
| |
741 | 741 |
| |
742 |
| - | |
743 |
| - | |
744 |
| - | |
| 742 | + | |
745 | 743 |
| |
746 | 744 |
| |
747 | 745 |
| |
| |||
764 | 762 |
| |
765 | 763 |
| |
766 | 764 |
| |
767 |
| - | |
| 765 | + | |
768 | 766 |
| |
769 |
| - | |
| 767 | + | |
770 | 768 |
| |
771 | 769 |
| |
772 | 770 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2890 | 2890 |
| |
2891 | 2891 |
| |
2892 | 2892 |
| |
2893 |
| - | |
| 2893 | + | |
2894 | 2894 |
| |
2895 | 2895 |
| |
2896 | 2896 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
179 | 179 |
| |
180 | 180 |
| |
181 | 181 |
| |
182 |
| - | |
| 182 | + | |
183 | 183 |
| |
184 | 184 |
| |
185 | 185 |
| |
| |||
551 | 551 |
| |
552 | 552 |
| |
553 | 553 |
| |
554 |
| - | |
| 554 | + | |
555 | 555 |
| |
556 | 556 |
| |
557 | 557 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
391 | 391 |
| |
392 | 392 |
| |
393 | 393 |
| |
394 |
| - | |
| 394 | + | |
395 | 395 |
| |
396 | 396 |
| |
397 | 397 |
| |
| |||
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 |
| - | |
| 410 | + | |
411 | 411 |
| |
412 | 412 |
| |
413 | 413 |
| |
|
Lines changed: 10 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
185 | 185 |
| |
186 | 186 |
| |
187 | 187 |
| |
188 |
| - | |
| 188 | + | |
189 | 189 |
| |
190 | 190 |
| |
191 | 191 |
| |
| |||
4262 | 4262 |
| |
4263 | 4263 |
| |
4264 | 4264 |
| |
4265 |
| - | |
| 4265 | + | |
4266 | 4266 |
| |
4267 | 4267 |
| |
4268 | 4268 |
| |
| |||
4315 | 4315 |
| |
4316 | 4316 |
| |
4317 | 4317 |
| |
4318 |
| - | |
4319 |
| - | |
| 4318 | + | |
4320 | 4319 |
| |
4321 | 4320 |
| |
4322 | 4321 |
| |
| |||
4331 | 4330 |
| |
4332 | 4331 |
| |
4333 | 4332 |
| |
4334 |
| - | |
4335 |
| - | |
4336 |
| - | |
| 4333 | + | |
4337 | 4334 |
| |
4338 | 4335 |
| |
4339 | 4336 |
| |
| |||
4508 | 4505 |
| |
4509 | 4506 |
| |
4510 | 4507 |
| |
4511 |
| - | |
| 4508 | + | |
4512 | 4509 |
| |
4513 | 4510 |
| |
4514 | 4511 |
| |
| |||
4524 | 4521 |
| |
4525 | 4522 |
| |
4526 | 4523 |
| |
4527 |
| - | |
| 4524 | + | |
4528 | 4525 |
| |
4529 | 4526 |
| |
4530 | 4527 |
| |
| |||
6607 | 6604 |
| |
6608 | 6605 |
| |
6609 | 6606 |
| |
6610 |
| - | |
6611 |
| - | |
| 6607 | + | |
6612 | 6608 |
| |
6613 | 6609 |
| |
6614 | 6610 |
| |
| |||
7786 | 7782 |
| |
7787 | 7783 |
| |
7788 | 7784 |
| |
7789 |
| - | |
| 7785 | + | |
7790 | 7786 |
| |
7791 | 7787 |
| |
7792 | 7788 |
| |
| |||
7817 | 7813 |
| |
7818 | 7814 |
| |
7819 | 7815 |
| |
7820 |
| - | |
7821 |
| - | |
| 7816 | + | |
7822 | 7817 |
| |
7823 | 7818 |
| |
7824 | 7819 |
| |
| |||
7838 | 7833 |
| |
7839 | 7834 |
| |
7840 | 7835 |
| |
7841 |
| - | |
| 7836 | + | |
7842 | 7837 |
| |
7843 | 7838 |
| |
7844 | 7839 |
| |
|
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3057 | 3057 |
| |
3058 | 3058 |
| |
3059 | 3059 |
| |
3060 |
| - | |
| 3060 | + | |
3061 | 3061 |
| |
3062 | 3062 |
| |
3063 | 3063 |
| |
| |||
3078 | 3078 |
| |
3079 | 3079 |
| |
3080 | 3080 |
| |
3081 |
| - | |
| 3081 | + | |
3082 | 3082 |
| |
3083 | 3083 |
| |
3084 | 3084 |
| |
| |||
3087 | 3087 |
| |
3088 | 3088 |
| |
3089 | 3089 |
| |
3090 |
| - | |
| 3090 | + | |
3091 | 3091 |
| |
3092 |
| - | |
| 3092 | + | |
3093 | 3093 |
| |
3094 | 3094 |
| |
3095 | 3095 |
| |
| |||
3137 | 3137 |
| |
3138 | 3138 |
| |
3139 | 3139 |
| |
3140 |
| - | |
| 3140 | + | |
3141 | 3141 |
| |
3142 | 3142 |
| |
3143 | 3143 |
| |
|
0 commit comments
Comments
(0)