forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6c82d8d
committed
Further reduce overhead for passing plpgsql variables to the executor.
This builds on commit21dcda2 by keepinga plpgsql function's shared ParamListInfo's entries for simple variables(PLPGSQL_DTYPE_VARs) valid at all times. That adds a few cycles to eachassignment to such variables, but saves significantly more cycles each timethey are used; so except in the pathological case of many dead stores, thisshould always be a win. Initial testing says it's good for about a 10%speedup of simple calculations; more in large functions with many datums.We can't use this method for row/record references unfortunately, so whatwe do for those is reset those ParamListInfo slots after use; which wecan skip doing unless some of them were actually evaluated during theprevious evaluation call. So this should frequently be a win as well,while worst case is that it's similar cost to the previous approach.Also, closer study suggests that the previous method of instantiating anew ParamListInfo array per evaluation is actually probably optimal forcursor-opening executor calls. The reason is that whatever is visible inthe array is going to get copied into the cursor portal via copyParamList.So if we used the function's main ParamListInfo for those calls, we'd endup with all of its DTYPE_VAR vars getting copied, which might well includelarge pass-by-reference values that the cursor actually has no need for.To avoid a possible net degradation in cursor cases, go back to creatingand filling a private ParamListInfo in those cases (which therefore will beexactly the same speed as before21dcda2). We still get some benefitout of this though, because this approach means that we only have to defendagainst copyParamList's try-to-fetch-every-slot behavior in the case of anunshared ParamListInfo; so plpgsql_param_fetch() can skip testingexpr->paramnos in the common case.To ensure that the main ParamListInfo's image of a DTYPE_VAR datum isalways valid, all assignments to such variables are now funneled throughassign_simple_var(). But this makes for cleaner and shorter code anyway.1 parent2524046 commit6c82d8d
3 files changed
+359
-207
lines changedLines changed: 59 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
| 107 | + | |
| 108 | + | |
107 | 109 |
| |
108 | 110 |
| |
109 | 111 |
| |
| |||
371 | 373 |
| |
372 | 374 |
| |
373 | 375 |
| |
374 |
| - | |
375 |
| - | |
376 |
| - | |
377 |
| - | |
378 |
| - | |
379 |
| - | |
380 |
| - | |
| 376 | + | |
381 | 377 |
| |
382 | 378 |
| |
383 | 379 |
| |
| |||
758 | 754 |
| |
759 | 755 |
| |
760 | 756 |
| |
761 |
| - | |
762 |
| - | |
763 |
| - | |
764 |
| - | |
| 757 | + | |
| 758 | + | |
765 | 759 |
| |
766 | 760 |
| |
767 | 761 |
| |
| |||
804 | 798 |
| |
805 | 799 |
| |
806 | 800 |
| |
807 |
| - | |
808 | 801 |
| |
809 | 802 |
| |
810 | 803 |
| |
| |||
860 | 853 |
| |
861 | 854 |
| |
862 | 855 |
| |
863 |
| - | |
864 |
| - | |
865 |
| - | |
866 |
| - | |
867 |
| - | |
| 856 | + | |
868 | 857 |
| |
869 | 858 |
| |
870 | 859 |
| |
| |||
911 | 900 |
| |
912 | 901 |
| |
913 | 902 |
| |
914 |
| - | |
915 |
| - | |
916 |
| - | |
917 |
| - | |
| 903 | + | |
| 904 | + | |
918 | 905 |
| |
919 | 906 |
| |
920 | 907 |
| |
| |||
1965 | 1952 |
| |
1966 | 1953 |
| |
1967 | 1954 |
| |
| 1955 | + | |
1968 | 1956 |
| |
1969 | 1957 |
| |
1970 | 1958 |
| |
| |||
2311 | 2299 |
| |
2312 | 2300 |
| |
2313 | 2301 |
| |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
2314 | 2318 |
| |
2315 | 2319 |
| |
2316 | 2320 |
| |
| |||
2329 | 2333 |
| |
2330 | 2334 |
| |
2331 | 2335 |
| |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
2332 | 2369 |
| |
2333 | 2370 |
| |
2334 | 2371 |
| |
|
0 commit comments
Comments
(0)