diff options
author | Monty <monty@mariadb.org> | 2021-10-09 16:16:10 +0300 |
---|---|---|
committer | Sergei Petrunia <sergey@mariadb.com> | 2023-02-02 20:49:35 +0300 |
commit | 956980971f98e1eb451e71856fe823470a5d1d32 (patch) | |
tree | 369d47e8f78d05c313d42e24492daaeb15c24e91 /mysql-test/main/opt_trace_selectivity.result | |
parent | 6fa7451759e0832cc13a0e47a8300292b96bdb75 (diff) | |
download | mariadb-git-956980971f98e1eb451e71856fe823470a5d1d32.tar.gz |
Update cost for hash and cached joins
The old code did not't correctly add TIME_FOR_COMPARE to rows that are
part of the scan that will be compared with the attached where clause.
Now the cost calculation for hash join and full join cache join are
identical except for HASH_FANOUT (10%)
The cost for a join with keys is now also uniform.
The total cost for a using a key for lookup is calculated in one place as:
(cost_of_finding_rows_through_key(records) + records/TIME_FOR_COMPARE)*
record_count_of_previous_row_combinations + startup_cost
startup_cost is the cost of a creating a temporary table (if needed)
Best_cost now includes the cost of comparing all WHERE clauses and also
cost of joining with previous row combinations.
Other things:
- Optimizer trace is now printing the total costs, including testing the
WHERE clause (TIME_FOR_COMPARE) and comparing with all previous rows.
- In optimizer trace, include also total cost of query together with the
final join order. This makes it easier to find out where the cost was
calculated.
- Old code used filter even if the cost for it was higher than not using a
filter. This is not corrected.
- When rebasing on 10.11, I noticed some changes to access_cost_factor
calculation. These changes was not picked as the coming changes
to filtering will make that code obsolete.
Diffstat (limited to 'mysql-test/main/opt_trace_selectivity.result')
-rw-r--r-- | mysql-test/main/opt_trace_selectivity.result | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result index 31eddaf5c10..86290a631fd 100644 --- a/mysql-test/main/opt_trace_selectivity.result +++ b/mysql-test/main/opt_trace_selectivity.result @@ -49,7 +49,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": true, "rows": 104, - "cost": 104.16562, + "cond_check_cost": 124.96562, + "startup_cost": 0, + "cost": 124.96562, "chosen": true }, { @@ -57,7 +59,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": true, "rows": 340, - "cost": 340.2577963, + "cond_check_cost": 408.2577963, + "startup_cost": 0, + "cost": 408.2577963, "chosen": false, "cause": "cost" }, @@ -66,7 +70,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "c", "used_range_estimates": true, "rows": 632, - "cost": 632.3718449, + "cond_check_cost": 758.7718449, + "startup_cost": 0, + "cost": 758.7718449, "chosen": false, "cause": "cost" }, @@ -137,7 +143,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "a", "used_range_estimates": true, "rows": 6, - "cost": 6.127343464, + "cond_check_cost": 7.327343464, + "startup_cost": 0, + "cost": 7.327343464, "chosen": true }, { @@ -145,7 +153,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "b", "used_range_estimates": true, "rows": 232, - "cost": 232.2156139, + "cond_check_cost": 278.6156139, + "startup_cost": 0, + "cost": 278.6156139, "chosen": false, "cause": "cost" }, @@ -154,7 +164,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "index": "c", "used_range_estimates": true, "rows": 293, - "cost": 293.2394392, + "cond_check_cost": 351.8394392, + "startup_cost": 0, + "cost": 351.8394392, "chosen": false, "cause": "cost" }, |