forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit50e17ad
committed
Speedup ScalarArrayOpExpr evaluation
ScalarArrayOpExprs with "useOr=true" and a set of Consts on the righthandside have traditionally been evaluated by using a linear search over thearray. When these arrays contain large numbers of elements then thislinear search could become a significant part of execution time.Here we add a new method of evaluating ScalarArrayOpExpr expressions toallow them to be evaluated by first building a hash table containing eachelement, then on subsequent evaluations, we just probe that hash table todetermine if there is a match.The planner is in charge of determining when this optimization is possibleand it enables it by setting hashfuncid in the ScalarArrayOpExpr. Theexecutor will only perform the hash table evaluation when the hashfuncidis set.This means that not all cases are optimized. For example CHECK constraintscontaining an IN clause won't go through the planner, so won't get thehashfuncid set. We could maybe do something about that at some laterdate. The reason we're not doing it now is from fear that we may slowdown cases where the expression is evaluated only once. Those cases canbe common, for example, a single row INSERT to a table with a CHECKconstraint containing an IN clause.In the planner, we enable this when there are suitable hash functions forthe ScalarArrayOpExpr's operator and only when there is at leastMIN_ARRAY_SIZE_FOR_HASHED_SAOP elements in the array. The threshold iscurrently set to 9.Author: James Coleman, David RowleyReviewed-by: David Rowley, Tomas Vondra, Heikki LinnakangasDiscussion:https://postgr.es/m/CAAaqYe8x62+=wn0zvNKCj55tPpg-JBHzhZFFc6ANovdqFw7-dA@mail.gmail.com1 parent1d25757 commit50e17ad
File tree
21 files changed
+712
-30
lines changed- src
- backend
- executor
- jit/llvm
- nodes
- optimizer
- path
- plan
- prep
- util
- parser
- partitioning
- include
- catalog
- executor
- nodes
- optimizer
- test/regress
- expected
- sql
21 files changed
+712
-30
lines changedLines changed: 81 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1149 | 1149 |
| |
1150 | 1150 |
| |
1151 | 1151 |
| |
| 1152 | + | |
| 1153 | + | |
1152 | 1154 |
| |
1153 | 1155 |
| |
1154 | 1156 |
| |
| |||
1163 | 1165 |
| |
1164 | 1166 |
| |
1165 | 1167 |
| |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1166 | 1179 |
| |
1167 | 1180 |
| |
1168 | 1181 |
| |
| |||
1171 | 1184 |
| |
1172 | 1185 |
| |
1173 | 1186 |
| |
1174 |
| - | |
1175 |
| - | |
1176 |
| - | |
1177 |
| - | |
1178 | 1187 |
| |
1179 |
| - | |
1180 |
| - | |
1181 |
| - | |
1182 |
| - | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1183 | 1193 |
| |
1184 |
| - | |
1185 |
| - | |
1186 |
| - | |
1187 |
| - | |
1188 |
| - | |
1189 |
| - | |
1190 |
| - | |
1191 |
| - | |
1192 |
| - | |
1193 |
| - | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
1194 | 1257 |
| |
1195 | 1258 |
| |
1196 | 1259 |
| |
|
0 commit comments
Comments
(0)