forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc238442
committed
Micro-optimize some slower queries in the opr_sanity regression test.
Convert the binary_coercible() and physically_coercible() functions fromSQL to plpgsql. It's not that plpgsql is inherently better at doingqueries; if you simply convert the previous single SQL query into oneRETURN expression, it's no faster. The problem with the existing codeis that it fools the plancache into deciding that it's worth re-planningthe query every time, since constant-folding with a concrete value for $2allows elimination of at least one sub-SELECT. In reality that's using theplanner to do the equivalent of a few runtime boolean tests, causing thefunction to run much slower than it should. Splitting the AND/OR logicinto separate plpgsql statements allows each if-expression to acquire astatic plan.Also, get rid of some uses of obj_description() in favor of explicitlyjoining to pg_description, allowing the joins to be optimized better.(Someday we might improve the SQL-function-inlining logic enough thatthis happens automatically, but today is not that day.)Together, these changes reduce the runtime of the opr_sanity regressiontest by about a factor of two on one of my slower machines. They don'tseem to help as much on a fast machine, but this should at least benefitthe buildfarm.1 parentbc920be commitc238442
2 files changed
+100
-52
lines changedLines changed: 50 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
23 |
| - | |
24 |
| - | |
25 |
| - | |
26 |
| - | |
27 |
| - | |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
32 |
| - | |
33 |
| - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 |
| |
35 | 43 |
| |
36 | 44 |
| |
37 |
| - | |
38 |
| - | |
39 |
| - | |
40 |
| - | |
41 |
| - | |
42 |
| - | |
43 |
| - | |
44 |
| - | |
45 |
| - | |
46 |
| - | |
47 |
| - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
48 | 64 |
| |
49 | 65 |
| |
50 | 66 |
| |
| |||
1190 | 1206 |
| |
1191 | 1207 |
| |
1192 | 1208 |
| |
1193 |
| - | |
| 1209 | + | |
1194 | 1210 |
| |
1195 |
| - | |
| 1211 | + | |
1196 | 1212 |
| |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1197 | 1217 |
| |
1198 | 1218 |
| |
1199 | 1219 |
| |
| |||
1210 | 1230 |
| |
1211 | 1231 |
| |
1212 | 1232 |
| |
1213 |
| - | |
| 1233 | + | |
1214 | 1234 |
| |
1215 |
| - | |
| 1235 | + | |
1216 | 1236 |
| |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1217 | 1241 |
| |
1218 | 1242 |
| |
1219 | 1243 |
| |
|
Lines changed: 50 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
27 |
| - | |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
32 |
| - | |
33 |
| - | |
34 |
| - | |
35 |
| - | |
36 |
| - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
37 | 45 |
| |
38 | 46 |
| |
39 | 47 |
| |
40 | 48 |
| |
41 |
| - | |
42 |
| - | |
43 |
| - | |
44 |
| - | |
45 |
| - | |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
50 |
| - | |
51 |
| - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
52 | 68 |
| |
53 | 69 |
| |
54 | 70 |
| |
| |||
725 | 741 |
| |
726 | 742 |
| |
727 | 743 |
| |
728 |
| - | |
| 744 | + | |
729 | 745 |
| |
730 |
| - | |
| 746 | + | |
731 | 747 |
| |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
732 | 752 |
| |
733 | 753 |
| |
734 | 754 |
| |
| |||
742 | 762 |
| |
743 | 763 |
| |
744 | 764 |
| |
745 |
| - | |
| 765 | + | |
746 | 766 |
| |
747 |
| - | |
| 767 | + | |
748 | 768 |
| |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
749 | 773 |
| |
750 | 774 |
| |
751 | 775 |
| |
|
0 commit comments
Comments
(0)