forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb62f94c
committed
Allow simplification of EXISTS() subqueries containing LIMIT.
The locution "EXISTS(SELECT ... LIMIT 1)" seems to be rather common amongpeople who don't realize that the database already performs optimizationsequivalent to putting LIMIT 1 in the sub-select. Unfortunately, this wasactually making things worse, because it prevented us from optimizing suchEXISTS clauses into semi or anti joins. Teach simplify_EXISTS_query() tosuppress constant-positive LIMIT clauses. That fixes the semi/anti-joincase, and may help marginally even for cases that have to be left assub-SELECTs.Marti Raudsepp, reviewed by David Rowley1 parent9c58101 commitb62f94c
File tree
3 files changed
+96
-9
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+96
-9
lines changedLines changed: 43 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
| 73 | + | |
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
| |||
452 | 452 |
| |
453 | 453 |
| |
454 | 454 |
| |
455 |
| - | |
| 455 | + | |
456 | 456 |
| |
457 | 457 |
| |
458 | 458 |
| |
| |||
518 | 518 |
| |
519 | 519 |
| |
520 | 520 |
| |
521 |
| - | |
| 521 | + | |
522 | 522 |
| |
523 | 523 |
| |
524 | 524 |
| |
| |||
1359 | 1359 |
| |
1360 | 1360 |
| |
1361 | 1361 |
| |
1362 |
| - | |
| 1362 | + | |
1363 | 1363 |
| |
1364 | 1364 |
| |
1365 | 1365 |
| |
| |||
1486 | 1486 |
| |
1487 | 1487 |
| |
1488 | 1488 |
| |
1489 |
| - | |
| 1489 | + | |
1490 | 1490 |
| |
1491 | 1491 |
| |
1492 | 1492 |
| |
1493 |
| - | |
1494 |
| - | |
1495 |
| - | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
1496 | 1497 |
| |
1497 | 1498 |
| |
1498 | 1499 |
| |
| |||
1501 | 1502 |
| |
1502 | 1503 |
| |
1503 | 1504 |
| |
1504 |
| - | |
1505 | 1505 |
| |
1506 | 1506 |
| |
1507 | 1507 |
| |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1508 | 1542 |
| |
1509 | 1543 |
| |
1510 | 1544 |
| |
|
Lines changed: 40 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
221 | 221 |
| |
222 | 222 |
| |
223 | 223 |
| |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
224 | 264 |
| |
225 | 265 |
| |
226 | 266 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
95 | 108 |
| |
96 | 109 |
| |
97 | 110 |
| |
|
0 commit comments
Comments
(0)