forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit497bac7
committed
Fix long-obsolete code for separating filter conditions in cost_index().
This code relied on pointer equality to identify which restriction clausesalso appear in the indexquals (and, therefore, don't need to be applied assimple filter conditions). That was okay once upon a time, years ago,before we introduced the equivalence-class machinery. Now there's about a50-50 chance that an equality clause appearing in the indexquals will bethe mirror image (commutator) of its mate in the restriction list. Whenthat happens, we'd erroneously think that the clause would be re-evaluatedat each visited row, and therefore inflate the cost estimate for theindexscan by the clause's cost.Add some logic to catch this case. It seems to me that it continues not tobe worthwhile to expend the extra predicate-proof work that createplan.cwill do on the finally-selected plan, but this case is common enough andcheap enough to handle that we should do so.This will make a small difference (about one cpu_operator_cost per row)in simple cases; but in situations where there's an expensive function inthe indexquals, it can make a very large difference, as seen in recentexample from Jeff Janes.This is a long-standing bug, but I'm hesitant to back-patch because of thepossibility of destabilizing plan choices that people may be happy with.1 parent5223dda commit497bac7
2 files changed
+61
-20
lines changedLines changed: 58 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
| 127 | + | |
127 | 128 |
| |
128 | 129 |
| |
129 | 130 |
| |
| |||
242 | 243 |
| |
243 | 244 |
| |
244 | 245 |
| |
245 |
| - | |
| 246 | + | |
246 | 247 |
| |
247 | 248 |
| |
248 | 249 |
| |
| |||
265 | 266 |
| |
266 | 267 |
| |
267 | 268 |
| |
268 |
| - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
269 | 273 |
| |
270 | 274 |
| |
271 | 275 |
| |
272 |
| - | |
273 |
| - | |
274 |
| - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
275 | 282 |
| |
276 | 283 |
| |
277 | 284 |
| |
278 | 285 |
| |
279 |
| - | |
280 |
| - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
281 | 289 |
| |
282 | 290 |
| |
283 | 291 |
| |
| |||
433 | 441 |
| |
434 | 442 |
| |
435 | 443 |
| |
436 |
| - | |
437 |
| - | |
438 |
| - | |
439 |
| - | |
440 |
| - | |
441 |
| - | |
442 |
| - | |
443 |
| - | |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 |
| - | |
448 |
| - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
449 | 447 |
| |
450 | 448 |
| |
451 | 449 |
| |
| |||
456 | 454 |
| |
457 | 455 |
| |
458 | 456 |
| |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
459 | 497 |
| |
460 | 498 |
| |
461 | 499 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1210 | 1210 |
| |
1211 | 1211 |
| |
1212 | 1212 |
| |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
1213 | 1216 |
| |
1214 | 1217 |
| |
1215 | 1218 |
| |
|
0 commit comments
Comments
(0)