forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7985398
committed
Clamp indexscan filter condition cost estimate to be not less than zero.
cost_index tries to estimate the per-tuple costs of evaluating filterconditions (a/k/a qpquals) by subtracting the estimated cost of theindexqual conditions from that of the baserestrictinfo conditions. This iscorrect so long as the indexquals list is a subset of the baserestrictinfolist. However, in the presence of derived indexable conditions it'scompletely wrong, leading to bogus or even negative scan cost estimates,as seen for example in bug #6579 from Istvan Endredy. In practice theproblem isn't severe except in the specific case of a LIKE optimization ona functional index containing a very expensive function.A proper fix for this might change cost estimates by more than people wouldlike for stable branches, so in the back branches let's just clamp the costdifference to be not less than zero. That will at least prevent completelyinsane behavior, while not changing the results normally.1 parent35400e1 commit7985398
1 file changed
+10
-1
lines changedLines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
392 | 392 |
| |
393 | 393 |
| |
394 | 394 |
| |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
395 | 403 |
| |
396 | 404 |
| |
397 | 405 |
| |
| |||
402 | 410 |
| |
403 | 411 |
| |
404 | 412 |
| |
405 |
| - | |
| 413 | + | |
| 414 | + | |
406 | 415 |
| |
407 | 416 |
| |
408 | 417 |
| |
|
0 commit comments
Comments
(0)