Commit 974f5a7
Chaithra Gopalareddy
Bug#21178196 : UPDATE MAY USE INDEX MERGE WITHOUT ANY REASON
(INCREASING CHANCES FOR DEADLOCK)
Problem:
Index merge access plan is choosen over range scan when the cost
for doing range scan would be same/less.
Analysis:
W.r.t the query presented in the bugpage, index merge access plan
is choosen because it is covering. However, while calculating the cost
for doing index merge scan, the current cost model thinks doing a sequential
scan is more costly than doing a random scan. For the given case,
while calculating the cost for disk sweep, we calculate cost for
reading the blocks having the qualifying rows and the cost for skipping
the other blocks. There is a minimal cost for skipping blocks too. And given
that in this case, we are looking at one qualifying row and rejecting 1590000
rows, we would end up skipping a lot of blocks. As a result the total cost
for doing sequential scan becomes larger than doing a random scan.
This in turn makes optimizer think doing index merge is better than the
other access plans.
Solution:
If it is calculated that sequential scan cost is more than random scan cost,
set the cost to random scan cost.
Also, set is_interrupted to true before calling get_sweep_read_cost
when the plan is not single table. This will make both single table select
and single table update choose the same code path. This is in line with
other calls made to get_sweep_read_cost.
Test case is not added as large amount of data is needed to get a repeatable
scenario.1 parent 01dab6b commit 974f5a7
3 files changed
Lines changed: 34 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3442 | 3442 | | |
3443 | 3443 | | |
3444 | 3444 | | |
3445 | | - | |
3446 | | - | |
| 3445 | + | |
| 3446 | + | |
3447 | 3447 | | |
3448 | 3448 | | |
3449 | 3449 | | |
| |||
3453 | 3453 | | |
3454 | 3454 | | |
3455 | 3455 | | |
3456 | | - | |
3457 | | - | |
| 3456 | + | |
| 3457 | + | |
3458 | 3458 | | |
3459 | 3459 | | |
3460 | 3460 | | |
| |||
3466 | 3466 | | |
3467 | 3467 | | |
3468 | 3468 | | |
3469 | | - | |
| 3469 | + | |
3470 | 3470 | | |
3471 | 3471 | | |
3472 | 3472 | | |
| |||
3475 | 3475 | | |
3476 | 3476 | | |
3477 | 3477 | | |
3478 | | - | |
| 3478 | + | |
3479 | 3479 | | |
3480 | 3480 | | |
3481 | 3481 | | |
| |||
3498 | 3498 | | |
3499 | 3499 | | |
3500 | 3500 | | |
3501 | | - | |
| 3501 | + | |
3502 | 3502 | | |
3503 | 3503 | | |
3504 | 3504 | | |
| |||
3530 | 3530 | | |
3531 | 3531 | | |
3532 | 3532 | | |
3533 | | - | |
| 3533 | + | |
3534 | 3534 | | |
3535 | 3535 | | |
3536 | 3536 | | |
3537 | 3537 | | |
3538 | | - | |
| 3538 | + | |
3539 | 3539 | | |
3540 | 3540 | | |
3541 | 3541 | | |
| |||
5519 | 5519 | | |
5520 | 5520 | | |
5521 | 5521 | | |
5522 | | - | |
5523 | | - | |
| 5522 | + | |
| 5523 | + | |
5524 | 5524 | | |
5525 | 5525 | | |
5526 | 5526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6642 | 6642 | | |
6643 | 6643 | | |
6644 | 6644 | | |
6645 | | - | |
6646 | | - | |
6647 | | - | |
| 6645 | + | |
| 6646 | + | |
| 6647 | + | |
| 6648 | + | |
| 6649 | + | |
| 6650 | + | |
| 6651 | + | |
| 6652 | + | |
6648 | 6653 | | |
6649 | | - | |
| 6654 | + | |
| 6655 | + | |
6650 | 6656 | | |
6651 | 6657 | | |
| 6658 | + | |
| 6659 | + | |
| 6660 | + | |
| 6661 | + | |
| 6662 | + | |
| 6663 | + | |
| 6664 | + | |
| 6665 | + | |
| 6666 | + | |
| 6667 | + | |
| 6668 | + | |
6652 | 6669 | | |
6653 | 6670 | | |
6654 | 6671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
5234 | 5234 | | |
5235 | 5235 | | |
5236 | 5236 | | |
5237 | | - | |
| 5237 | + | |
5238 | 5238 | | |
5239 | 5239 | | |
5240 | 5240 | | |
| |||
0 commit comments