MDEV-298: SHOW EXPLAIN: Plan returned by SHOW EXPLAIN only contains 'Using temporary' ...
- Correct the way SHOW EXPLAIN code calculates 'need_order' parameter for JOIN::print_explain(). The calculation is still an approximation (see MDEV entry for details) (even EXPLAIN itself is wrong in certain cases), but now it's a better approximation than before.
This commit is contained in:
parent
ab70b76d9c
commit
8950ed8fdd
@ -888,4 +888,42 @@ a+SLEEP(0.01)
|
|||||||
0
|
0
|
||||||
set debug_dbug='';
|
set debug_dbug='';
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
#
|
||||||
|
# MDEV-298: SHOW EXPLAIN: Plan returned by SHOW EXPLAIN only contains
|
||||||
|
# 'Using temporary' while the standard EXPLAIN says 'Using temporary; Using filesort'
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT);
|
||||||
|
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),
|
||||||
|
(10),(11),(12),(13),(14),(15),(16);
|
||||||
|
INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12, t1 t13;
|
||||||
|
EXPLAIN SELECT a FROM t1 GROUP BY a;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4112 Using temporary; Using filesort
|
||||||
|
set @show_explain_probe_select_id=1;
|
||||||
|
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||||
|
SELECT a FROM t1 GROUP BY a;
|
||||||
|
show explain for $thr2;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 4112 Using temporary; Using filesort
|
||||||
|
Warnings:
|
||||||
|
Note 1003 SELECT a FROM t1 GROUP BY a
|
||||||
|
a
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
set debug_dbug='';
|
||||||
|
drop table t1;
|
||||||
drop table t0;
|
drop table t0;
|
||||||
|
@ -919,5 +919,33 @@ reap;
|
|||||||
set debug_dbug='';
|
set debug_dbug='';
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-298: SHOW EXPLAIN: Plan returned by SHOW EXPLAIN only contains
|
||||||
|
--echo # 'Using temporary' while the standard EXPLAIN says 'Using temporary; Using filesort'
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (a INT);
|
||||||
|
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),
|
||||||
|
(10),(11),(12),(13),(14),(15),(16);
|
||||||
|
INSERT INTO t1 SELECT t11.a FROM t1 t11, t1 t12, t1 t13;
|
||||||
|
|
||||||
|
EXPLAIN SELECT a FROM t1 GROUP BY a;
|
||||||
|
|
||||||
|
set @show_explain_probe_select_id=1;
|
||||||
|
set debug_dbug='d,show_explain_probe_join_exec_start';
|
||||||
|
--send
|
||||||
|
SELECT a FROM t1 GROUP BY a;
|
||||||
|
|
||||||
|
connection default;
|
||||||
|
--source include/wait_condition.inc
|
||||||
|
evalp show explain for $thr2;
|
||||||
|
|
||||||
|
connection con1;
|
||||||
|
reap;
|
||||||
|
|
||||||
|
set debug_dbug='';
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
drop table t0;
|
drop table t0;
|
||||||
|
|
||||||
|
@ -4100,7 +4100,8 @@ int st_select_lex::print_explain(select_result_sink *output,
|
|||||||
{
|
{
|
||||||
res= join->print_explain(output, explain_flags, TRUE,
|
res= join->print_explain(output, explain_flags, TRUE,
|
||||||
join->need_tmp, // need_tmp_table
|
join->need_tmp, // need_tmp_table
|
||||||
(join->order != 0 && !join->skip_sort_order), // bool need_order
|
!join->skip_sort_order && !join->no_order &&
|
||||||
|
(join->order || join->group_list), // bool need_order
|
||||||
join->select_distinct, // bool distinct
|
join->select_distinct, // bool distinct
|
||||||
NULL); //const char *message
|
NULL); //const char *message
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user