Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
11.0(EOL)
-
None
Description
Range cost cost calculations does not take into account join_buffer.
When 11.0 optimizer was coded, the assumption was that RANGE queries will not use the join buffer (and join buffer flag was not set for these).
The optimizer would however decide later to use join buffer, which means that the cost
calculations for ranges did not match reality, which could mean that the optimizer could
use a worse plan.
The task is to fix that range + join_buffer cost is calculated correctly.
This is a bit complex to do as the 'range total cost' that best_access_plan() is not specific
enough to allow correct calculation of range + join_buffer.
Attachments
Issue Links
- causes
-
MDEV-31445 Server crashes in ha_partition::index_blocks / cost_for_index_read
-
- Closed
-
-
MDEV-31494 Server crashes in ha_partition::index_blocks / get_key_scans_params
-
- Closed
-
MDEV-31356: Range cost calculations does not take into account join_bufferThis patch also fixes
MDEV-31391Assertion `((best.records_out) == 0.0 ... failedCost changes caused by this change:
properly applied to it in all cases (this extra cost is equal to a
key lookup).
the engine after the first scan pass. (We did this before for range
scans and other access methods).
max_index_blocks. Correcting this, causes range access on
partitioned tables to have slightly higher cost because of the
increased estimated IO.
wrong. (Only affected EXPLAIN, not query costs).
statistics, but did not adjust cost. Now fixed.
The big change in the patch are:
'ALL_READ_COST cost' and only converting it to a double at the end.
This allows us to more exactly calculate the effect of the join_cache.
ALL_READ_COST object.
One of effect if this change is that when joining very small tables:
t1 some_access_method
t2 range
t3 ALL Use join buffer
This is swiched to
t1 some_access_method
t3 ALL
t2 range use join buffer
Both plans has the same cost, but as table scan in this case has less
cost than rang, the table scan will be considered first and thus have
precidence.
Test case changes:
range setup cost.