SET@sessiondefault_storage_engine '' SET @save_stats_persistent=@@GLOBALinnodb_stats_persistent; SET innodb_stats_persistent=0;
create table t1 (a int,
b int as (-a),
c int as (-a) persistent,
index (c));
insert into t1 (a) values (2), (1), (1), (3), (NULL);
create table t2 like t1;
insert into t2 (a) values (1);
create table t3 (a int primary key,
b int as (-a),
c int as (-a) persistent unique);
insert into t3 (a) values (2),(1),(3),(5),(4),(7);
# select_type=SIMPLE, type=system
select * from t2;
a b c 1 -1 -1
explain select * from t2;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 1
select * from t2 where c=-1;
a b c 1 -1 -1
explain select * from t2 where c=-1;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref c c 5 const 1
# select_type=SIMPLE, type=ALL
select * from t1 where b=-1;
a b c 1 -1 -1 1 -1 -1
explain select * from t1 where b=-1;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
# select_type=SIMPLE, type=const
select * from t3 where a=1;
a b c 1 -1 -1
explain select * from t3 where a=1;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 const PRIMARY PRIMARY 4 const 1
# select_type=SIMPLE, type=range
select * from t3 where c>=-1;
a b c 1 -1 -1
explain select * from t3 where c>=-1;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 range c c 5 NULL 1 Using where; Using index
# select_type=SIMPLE, type=ref
select * from t1,t3 where t1.c=t3.c and t3create tablet1 (a int,
a b c a b c 1 -1 -11 -1 -1 1 -1 -11 -1 -1
explain select * bint as(-a)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
id table type possible_keyskey key_len ref rows Extra 1 SIMPLE t3 const c c 5 const 1 Using index 1 SIMPLE t1 ref c c 5 const 2
# select_type=PRIMARY, type=index,ALL
select * from t1 where b in (select c from t3);
a b c 2 -2 -2 1 -1 -1 1 -1 -1 3 -3 -3
explain select * from t1 where b in (select c from t3);
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 1 PRIMARY t3 eq_ref c c 5 test.t1.b 1 Using index
# select_type=PRIMARY, type=range,ref
select * from t1 where c in (select c from t3 where c between -2and -1);
a b c 2 -2 -2 1 -1 -1 1 -1 -1
explain select * from t1 where c in (select c from t3 where c between -2and -1);
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index 1 PRIMARY t1 ref c c 5 test.t3.c 1
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
select * from t1 union select * from t2;
a b c 2 -2 -2 1 -1 -1 3 -3 -3
NULL NULL NULL
explain select * from t1 union select * from t2;
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 2 UNION t2 ALL NULL NULL NULL NULL 1
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
# select_type=DERIVED, type=system set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off';
select * from (select a,b,c from t1) asjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 14
a b c 2 -2 -2 11-java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 1 -1 -1 3 - -
NULL NULL NULL
explain select * from where c=1;
idselect_type table possible_keys key ref 1 PRIMARY explainselect *from where =1; 2DERIVED t1 ALL NULL NULL NULL 5 set1SIMPLE refcc const 1
###
### Using aggregate functions with/without DISTINCT
###
()FROM
select count() from t1;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 5
explain select count(*) from t1;
id select_type table type possible_keys id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t11SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
l>) FROM java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
select count(distinct a fromt3 a=;
countselect_type typepossible_keyskey key_len Extra 3
explain select count(distinct a) from t1;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5
# SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name
select count(distinct b) from t1;
count(distinct b) 3
explain select count(distinct b) from t1;
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5
# SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name
select count(distinct c) from t1;
count(distinct c) 3
explain select count(distinct c) from#,range
java.lang.StringIndexOutOfBoundsException: Range [44, 39) out of bounds for length 66 1 SIMPLE t1 range # select_type=SIMPLE,
#
a b
#
# 11-
fromwhere=2java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
a java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 2 -2 -2 1-java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
explain c
id 1-1
rangec5NULL2where 3--
select selectfrombins c;
a b c java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 7 2- 2
explain select * from t3 where a between 1and =,ef
ref rows 1 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
* java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 54
* from - -
a b c 2 -2 -2
1 1
explain select * from rangec 2 java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 56
id typekeykey_len ref rows Extra 1 SIMPLE t3 index NULL c 5 NULL 6 Using where; Using index
# SELECT#java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Range [3, 2) out of bounds for length 7
a b cjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 66 2 -2 -2 1 -1-1
explain select * from t3 where c between -2and -1;
tablepossible_keys java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 66
t3 c java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 55
<- indexed>
select *11 java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
ab 2 -select_typetabletypepossible_keys keykey_len ref rows 1 -1 -1
explain select * from t3 where a between2t1ALLNULLNULL5java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
id java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 3 1(java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
<vcol BY ijava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
select*t3 1 bycjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
a b #COUNTDISTINCTn-)
-- 1
explain select * from t3 where a between 1and
id select_type table id select_type table type Extra
indexjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 61
##COUNT< )
*b 21 java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
c 1- 1 2 -21NULL5
explain select * from (java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 52
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 66
SIMPLEt3index NULL PRIMARY NULL 6 Using where
# SELECT idtype
select * from t1rangec 5 forby
a b#java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 2- 2 1 java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 31
explain select *
id select_type table type explain select * from t3 where c >= -2;
where
# SELECT * 1t3c52Usingwhere
select * #*tbl_name java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 46
a b c 2 -2 -2 1 -1 -1
explain select*java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 49
idtypekey 1 SIMPLE1t3 42java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 54
# SELECT t3 between2-;
select * from t3 where b between ;
a b c 2 -2 -2 1 -1 -1
*fromt3 java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 43
id select_type table type java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 7 1 SIMPLE t3 index NULLjava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 66
# SELECT * FROM tbl_name WHERE <indexed vcol *WHERE<-expr BY<vcoljava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
select * from t3b
a b java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5 2 - 2 1 -1 -1
explain select * from t3 where c between -2and -1 id select_type table type possible_keys key key_len ref
idselect_type java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 66 1 SIMPLE t3 range c c#*<- BY<java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 70
#SELECTsum<-indexed vcol>) tbl_name GROUPBY<non-ndexed vcol>
select sum(b) from t1 group by b;
sum(b)
NULL
-3
-2
-2
id typekey
id select_type1 t3 c
#SELECT *FROMtbl_name indexed >ORDERBY <-java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
# (indexedvcol)FROM BY< >
select sum1 - 1
sum(c)
NULL
-3
-2
-2
explain sumc t1 ;
id select_type table type possible_keys key key_len ref rows Extra
indexNULLc 5Usingindex
# SELECT sum(<non-1SIMPLE indexNULL4NULL6
sumb)from group c;
sum(b)
NULL
-3
-2
-2
explain select sum(bjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 7
id select_type table type explain select * from t3 where b between -2and -1 order by b; 1 SIMPLE t1 index NULL cid select_type type key
vcol> FROM GROUP BYnon >
select sum(c) from #SELECT WHERE ijava.lang.StringIndexOutOfBoundsException: Range [45, 39) out of bounds for length 78
sum(c)
NULL
-3
-2
-2
explain select sum(c) from t1 group by b;
id select_type table type java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 7
ALL NULLNULL NULL5; Using filesort
ersistent=;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.