- Notifications
You must be signed in to change notification settings - Fork5.2k
Commitc0962a1
committed
Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate
This commit implements the automatic conversion of 'x IN (VALUES ...)' intoScalarArrayOpExpr. That simplifies the query tree, eliminating the appearanceof an unnecessary join.Since VALUES describes a relational table, and the value of such a list isa table row, the optimizer will likely face an underestimation problem due tothe inability to estimate cardinality through MCV statistics. The cardinalityevaluation mechanism can work with the array inclusion check operation.If the array is small enough (< 100 elements), it will perform a statisticalevaluation element by element.We perform the transformation in the convert_ANY_sublink_to_join() if VALUESRTE is proper and the transformation is convertible. The conversion is onlypossible for operations on scalar values, not rows. Also, we currentlysupport the transformation only when it ends up with a constant array.Otherwise, the evaluation of non-hashed SAOP might be slower than thecorresponding Hash Join with VALUES.Discussion:https://postgr.es/m/0184212d-1248-4f1f-a42d-f5cb1c1976d2%40tantorlabs.comAuthor: Alena Rybakina <a.rybakina@postgrespro.ru>Author: Andrei Lepikhov <lepihov@gmail.com>Reviewed-by: Ivan Kush <ivan.kush@tantorlabs.com>Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>1 parentd48d2e2 commitc0962a1
File tree
6 files changed
+512
-5
lines changed- src
- backend/optimizer
- plan
- prep
- util
- include/optimizer
- test/regress
- expected
- sql
6 files changed
+512
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1214 | 1214 | | |
1215 | 1215 | | |
1216 | 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 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
1217 | 1297 | | |
1218 | 1298 | | |
1219 | 1299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
667 | 679 | | |
668 | 680 | | |
669 | 681 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5484 | 5484 | | |
5485 | 5485 | | |
5486 | 5486 | | |
| 5487 | + | |
5487 | 5488 | | |
5488 | 5489 | | |
| 5490 | + | |
| 5491 | + | |
5489 | 5492 | | |
5490 | 5493 | | |
5491 | 5494 | | |
5492 | 5495 | | |
| 5496 | + | |
5493 | 5497 | | |
5494 | 5498 | | |
5495 | | - | |
5496 | | - | |
5497 | | - | |
| 5499 | + | |
| 5500 | + | |
5498 | 5501 | | |
5499 | 5502 | | |
5500 | | - | |
5501 | | - | |
| 5503 | + | |
| 5504 | + | |
5502 | 5505 | | |
5503 | 5506 | | |
5504 | 5507 | | |
5505 | 5508 | | |
5506 | 5509 | | |
| 5510 | + | |
5507 | 5511 | | |
5508 | 5512 | | |
5509 | 5513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
0 commit comments
Comments
(0)