Commit 33af691f authored by Monty's avatar Monty

Updated comments in best_access_path()

parent 0eca91ab
...@@ -8117,11 +8117,13 @@ best_access_path(JOIN *join, ...@@ -8117,11 +8117,13 @@ best_access_path(JOIN *join,
DBUG_ENTER("best_access_path"); DBUG_ENTER("best_access_path");
/* /*
Assume that there is at least one accepted row from previous table combinations. Assume that there is at least one accepted row from previous table
This fixes a problem when the selectivity for the preceding table combinations combinations.
becomes so high that record_count becomes << 1.0, which makes the cost for the This fixes a problem when the selectivity for the preceding table
current table so low that it does not matter when calculating the best plans. combinations becomes so high that record_count becomes << 1.0,
*/ which makes the cost for the current table so low that it does not
matter when calculating the best plans.
*/
set_if_bigger(record_count, 1.0); set_if_bigger(record_count, 1.0);
best.cost= DBL_MAX; best.cost= DBL_MAX;
...@@ -9123,17 +9125,15 @@ best_access_path(JOIN *join, ...@@ -9123,17 +9125,15 @@ best_access_path(JOIN *join,
{ {
/* /*
Simple scan Simple scan
We estimate we have to read org_records rows.
For each record we have to: records_after_filter rows will survive the where check of constants.
- Read the table record 'best.records_out' rows will survive after the check against columns
- Compare with the current WHERE clause from previous tables.
We estmate that 'rnd_records' will survive this check.
*/ */
scan_type= "scan"; scan_type= "scan";
/* /*
If this is not the first table we have to compare the rows against We have to compare each row set against all previous row combinations
all previous row combinations
*/ */
cur_cost= COST_MULT(cur_cost, record_count); cur_cost= COST_MULT(cur_cost, record_count);
} }
...@@ -9143,9 +9143,8 @@ best_access_path(JOIN *join, ...@@ -9143,9 +9143,8 @@ best_access_path(JOIN *join,
double cmp_time, row_copy_cost, refills; double cmp_time, row_copy_cost, refills;
/* /*
Calculate cost of checking the the WHERE for this table. Note that the cost of checking all rows against the table specific
This is done before we check the TABLE rows aginst the rows WHERE is already included in cur_cost.
in the join cache.
*/ */
scan_type= "scan_with_join_cache"; scan_type= "scan_with_join_cache";
...@@ -9158,7 +9157,10 @@ best_access_path(JOIN *join, ...@@ -9158,7 +9157,10 @@ best_access_path(JOIN *join,
/* We come here only if there are already rows in the join cache */ /* We come here only if there are already rows in the join cache */
DBUG_ASSERT(idx != join->const_tables); DBUG_ASSERT(idx != join->const_tables);
/* /*
Cost of: records_after_filter is the number of rows that have survived
the table specific WHERE check that only involves constants.
Calculate cost of:
- Copying all previous record combinations to the join cache - Copying all previous record combinations to the join cache
- Copying the tables from the join cache to table records - Copying the tables from the join cache to table records
- Checking the WHERE against the final row combination - Checking the WHERE against the final row combination
...@@ -9206,7 +9208,8 @@ best_access_path(JOIN *join, ...@@ -9206,7 +9208,8 @@ best_access_path(JOIN *join,
*/ */
best.cost= cur_cost; best.cost= cur_cost;
best.records_read= org_records; // Records accessed best.records_read= org_records; // Records accessed
best.records= records_after_filter; // Records to be checked with WHERE best.records= records_after_filter; // Records to be checked against
// previous row combinations
/* /*
If we are using 'use_cond_selectivity > 1' then If we are using 'use_cond_selectivity > 1' then
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment