diff options
author | Igor Babaev <igor@askmonty.org> | 2011-12-24 08:55:10 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-12-24 08:55:10 -0800 |
commit | 2b1f0b875775b65496e959db7f54f6eb4220400e (patch) | |
tree | 13c9bd8ec3780974596279996d8215caf21c5225 /mysql-test/r/explain.result | |
parent | 5d9fbc617724ce0bb7f90090596772dbb792139d (diff) | |
download | mariadb-git-2b1f0b875775b65496e959db7f54f6eb4220400e.tar.gz |
Back-ported the patch of the mysql-5.6 code line that
fixed several defects in the greedy optimization:
1) The greedy optimizer calculated the 'compare-cost' (CPU-cost)
for iterating over the partial plan result at each level in
the query plan as 'record_count / (double) TIME_FOR_COMPARE'
This cost was only used locally for 'best' calculation at each
level, and *not* accumulated into the total cost for the query plan.
This fix added the 'CPU-cost' of processing 'current_record_count'
records at each level to 'current_read_time' *before* it is used as
'accumulated cost' argument to recursive
best_extension_by_limited_search() calls. This ensured that the
cost of a huge join-fanout early in the QEP was correctly
reflected in the cost of the final QEP.
To get identical cost for a 'best' optimized query and a
straight_join with the same join order, the same change was also
applied to optimize_straight_join() and get_partial_join_cost()
2) Furthermore to get equal cost for 'best' optimized query and a
straight_join the new code substrcated the same '0.001' in
optimize_straight_join() as it had been already done in
best_extension_by_limited_search()
3) When best_extension_by_limited_search() aggregated the 'best' plan a
plan was 'best' by the check :
'if ((search_depth == 1) || (current_read_time < join->best_read))'
The term '(search_depth == 1' incorrectly caused a new best plan to be
collected whenever the specified 'search_depth' was reached - even if
this partial query plan was more expensive than what we had already
found.
Diffstat (limited to 'mysql-test/r/explain.result')
-rw-r--r-- | mysql-test/r/explain.result | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index 52c58f088a1..e08e3e22307 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -196,13 +196,13 @@ create table t2 (dt datetime not null); insert into t1 values ('2001-01-01 1:1:1', '1:1:1'), ('2001-01-01 1:1:1', '1:1:1'); insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='semijoin_with_cache=off'; +SET @save_join_cache_level=@@join_cache_level; +SET join_cache_level=0; flush tables; EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; Start temporary; End temporary +1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; FirstMatch(OUTR) flush tables; SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); dt @@ -210,13 +210,13 @@ flush tables; EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where -1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; Start temporary; End temporary +1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; FirstMatch(OUTR) flush tables; SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); dt 2001-01-01 01:01:01 2001-01-01 01:01:01 -SET optimizer_switch=@save_optimizer_switch; +SET join_cache_level=@save_join_cache_level; drop tables t1, t2; # # Bug#47669: Query showed by EXPLAIN EXTENDED gives different result from original query |