Skip to content

Commit 0925ab9

Browse files
committed
MDEV-406: ANALYZE $stmt
-Add analyze_stmt.test/result
1 parent eaba1ba commit 0925ab9

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

mysql-test/r/analyze_stmt.result

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
drop table if exists t0,t1,t2,t3;
2+
create table t0 (a int) engine=myisam;
3+
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
4+
create table t1 (a int) engine=myisam;
5+
INSERT INTO t1 select * from t0;
6+
# Try a few basic selects to see that r_rows and r_filtered columns work
7+
analyze select * from t1;
8+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
9+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00
10+
analyze select * from t1 where a<5;
11+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
12+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
13+
analyze select * from t1 where a>100;
14+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
15+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 0.00 Using where
16+
# ANALYZE DELETE will delete rows:
17+
analyze delete from t1 where a in (2,3,4);
18+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
19+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 NULL 100.00 30.00 Using where
20+
select * from t1;
21+
a
22+
0
23+
1
24+
5
25+
6
26+
7
27+
8
28+
9
29+
drop table t1;
30+
# ANALYZE UPDATE will make updates:
31+
create table t1(a int, b int);
32+
insert into t1 select a,a from t0;
33+
analyze update t1 set b=100+b where a in (6,7,8);
34+
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
35+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 NULL 100.00 30.00 Using where
36+
select * from t1;
37+
a b
38+
0 0
39+
1 1
40+
2 2
41+
3 3
42+
4 4
43+
5 5
44+
6 106
45+
7 107
46+
8 108
47+
9 9
48+
drop table t1;
49+
drop table t0;

mysql-test/t/analyze_stmt.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Tests for "ANALYZE $statement" feature (PostgreSQL's analog is called EXPLAIN ANALYZE)
3+
#
4+
--disable_warnings
5+
drop table if exists t0,t1,t2,t3;
6+
--enable_warnings
7+
8+
create table t0 (a int) engine=myisam;
9+
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
10+
11+
create table t1 (a int) engine=myisam;
12+
INSERT INTO t1 select * from t0;
13+
14+
--echo # Try a few basic selects to see that r_rows and r_filtered columns work
15+
analyze select * from t1;
16+
analyze select * from t1 where a<5;
17+
analyze select * from t1 where a>100;
18+
19+
--echo # ANALYZE DELETE will delete rows:
20+
analyze delete from t1 where a in (2,3,4);
21+
select * from t1;
22+
drop table t1;
23+
24+
--echo # ANALYZE UPDATE will make updates:
25+
create table t1(a int, b int);
26+
insert into t1 select a,a from t0;
27+
analyze update t1 set b=100+b where a in (6,7,8);
28+
select * from t1;
29+
drop table t1;
30+
31+
drop table t0;

0 commit comments

Comments
 (0)