@@ -6,17 +6,17 @@ INSERT INTO t1 select * from t0;
66# Try a few basic selects to see that r_rows and r_filtered columns work
77analyze select * from t1;
88id 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
9+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00
1010analyze select * from t1 where a<5;
1111id 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
12+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where
1313analyze select * from t1 where a>100;
1414id 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
15+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 0.00 Using where
1616# ANALYZE DELETE will delete rows:
1717analyze delete from t1 where a in (2,3,4);
1818id 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 10 100.00 30.00 Using where
19+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 30.00 Using where
2020select * from t1;
2121a
22220
@@ -32,7 +32,7 @@ create table t1(a int, b int);
3232insert into t1 select a,a from t0;
3333analyze update t1 set b=100+b where a in (6,7,8);
3434id 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 10 100.00 30.00 Using where
35+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 30.00 Using where
3636select * from t1;
3737a b
38380 0
@@ -51,14 +51,14 @@ create table t1(a int, b int);
5151insert into t1 select a,a from t0;
5252analyze (select * from t1 A where a<5) union (select * from t1 B where a in (5,6));
5353id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
54- 1 PRIMARY A ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
55- 2 UNION B ALL NULL NULL NULL NULL 10 10 100.00 20.00 Using where
56- NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 7 NULL NULL
54+ 1 PRIMARY A ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where
55+ 2 UNION B ALL NULL NULL NULL NULL 10 10.00 100.00 20.00 Using where
56+ NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 7.00 NULL NULL
5757analyze (select * from t1 A where a<5) union (select * from t1 B where a in (1,2));
5858id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
59- 1 PRIMARY A ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
60- 2 UNION B ALL NULL NULL NULL NULL 10 10 100.00 20.00 Using where
61- NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 5 NULL NULL
59+ 1 PRIMARY A ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where
60+ 2 UNION B ALL NULL NULL NULL NULL 10 10.00 100.00 20.00 Using where
61+ NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 5.00 NULL NULL
6262drop table t1;
6363drop table t0;
6464#
@@ -72,12 +72,12 @@ insert into t1 values (1,1),(2,2),(3,3);
7272# See .test file for the right values of r_rows and r_filtered.
7373analyze select a, a in (select t0.b from t0 where t0.b+1=t1.b+1) from t1;
7474id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
75- 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 3 100.00 100.00
76- 2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 3 100.00 33.33 Using where
75+ 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
76+ 2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 3.00 100.00 33.33 Using where
7777# Try a subquery that is never executed
7878analyze select a, a in (select t0.b from t0 where t0.b+1=t1.b+1) from t1 where t1.a > 5;
7979id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
80- 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 3 100.00 0.00 Using where
80+ 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 3.00 100.00 0.00 Using where
81812 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 NULL 100.00 NULL Using where
8282drop table t0, t1;
8383#
@@ -95,26 +95,26 @@ id select_type table type possible_keys key key_len ref rows Extra
9595# These should have filtered=50
9696analyze select * from t0, t1 where t0.a<5 and t1.a<5;
9797id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
98- 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
99- 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where; Using join buffer (flat, BNL join)
98+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where
99+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where; Using join buffer (flat, BNL join)
100100explain select * from t0, t1 where t0.a<5 and t1.b=t0.b;
101101id select_type table type possible_keys key key_len ref rows Extra
1021021 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
1031031 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
104104# Now, t1 should have filtered=10
105105analyze select * from t0, t1 where t0.a<5 and t1.b=t0.b;
106106id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
107- 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
108- 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 10.00 Using where; Using join buffer (flat, BNL join)
107+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where
108+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where; Using join buffer (flat, BNL join)
109109explain select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
110110id select_type table type possible_keys key key_len ref rows Extra
1111111 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
1121121 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
113113# Now, t1 should have filtered=10
114114analyze select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
115115id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
116- 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 50.00 Using where
117- 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 10.00 Using where; Using join buffer (flat, BNL join)
116+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 100.00 50.00 Using where
117+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 10.00 Using where; Using join buffer (flat, BNL join)
118118# TODO: Check what is counted for "range checked for each record".
119119#
120120# Test for joins
@@ -127,13 +127,13 @@ from t0 A, t0 B, t0 C;
127127# This always has matches, filtered=100%.
128128analyze select * from t1,t2 where t2.key1=t1.a;
129129id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
130- 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
131- 1 SIMPLE t2 ref key1 key1 5 test.t1.a 1 1 100.00 100.00
130+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00 Using where
131+ 1 SIMPLE t2 ref key1 key1 5 test.t1.a 1 1.00 100.00 100.00
132132# This shows r_rows=0. It is actually 0.5 (should r_rows be changed to double?)
133133analyze select * from t1,t2 where t2.key2x=t1.a;
134134id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
135- 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
136- 1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0 100.00 100.00
135+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00 Using where
136+ 1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0.50 100.00 100.00
137137select * from t1,t2 where t2.key2x=t1.a;
138138a b key1 key2x col1
1391390 0 0 0 0
@@ -144,8 +144,8 @@ a b key1 key2x col1
144144# This has t2.filtered=40% (there are 5 values: {0,1,2,3,4}. two of them have mod=0)
145145analyze select * from t1,t2 where t2.key2x=t1.a and mod(t2.col1,4)=0;
146146id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
147- 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
148- 1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0 100.00 40.00 Using where
147+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00 Using where
148+ 1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0.50 100.00 40.00 Using where
149149drop table t0,t1,t2;
150150#
151151# Check non-merged derived tables
@@ -156,8 +156,8 @@ insert into t0 values
156156update t0 set b=b/3;
157157analyze select * from (select count(*),max(a),b from t0 group by b) T;
158158id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
159- 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10 4 100.00 100.00
160- 2 DERIVED t0 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using temporary; Using filesort
159+ 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10 4.00 100.00 100.00
160+ 2 DERIVED t0 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00 Using temporary; Using filesort
161161drop table t0;
162162#
163163# Check ORDER/GROUP BY
@@ -167,7 +167,7 @@ insert into t0 values
167167(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
168168analyze select count(*),max(a),b from t0 where a<7 group by b;
169169id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
170- 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 70.00 Using where; Using temporary; Using filesort
170+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00 100.00 70.00 Using where; Using temporary; Using filesort
171171drop table t0;
172172#
173173# Check multi-table UPDATE/DELETE.
@@ -178,21 +178,21 @@ insert into t0 values (0,0),(2,2),(4,4), (8,8);
178178insert into t1 values (0,0),(2,2), (6,6);
179179analyze select * from t0,t1 where t0.a=t1.a;
180180id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
181- 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 3 100.00 100.00
182- 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4 100.00 16.67 Using where; Using join buffer (flat, BNL join)
181+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
182+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4.00 100.00 16.67 Using where; Using join buffer (flat, BNL join)
183183analyze update t0,t1 set t1.b=5555 where t0.a=t1.a;
184184id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
185- 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 3 100.00 100.00
186- 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4 100.00 16.67 Using where
185+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
186+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4.00 100.00 16.67 Using where
187187select * from t1;
188188a b
1891890 5555
1901902 5555
1911916 6
192192analyze delete t1 from t1, t0 where t0.a=t1.a;
193193id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
194- 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 3 100.00 100.00
195- 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4 100.00 16.67 Using where
194+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
195+ 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4.00 100.00 16.67 Using where
196196select * from t1;
197197a b
1981986 6
@@ -240,7 +240,7 @@ create table t1 (i int);
240240insert into t1 values (1),(2),(3),(4);
241241analyze update t1 set i=8;
242242id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
243- 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4 100.00 100.00
243+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
244244drop table t1;
245245#
246246# Check ANALYZE SELECT INTO
@@ -257,7 +257,7 @@ drop table t1;
257257create table t1 (i int);
258258analyze delete from t1 returning *;
259259id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
260- 1 SIMPLE t1 ALL NULL NULL NULL NULL 0 0 100.00 100.00
260+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 0 0.00 100.00 100.00
261261drop table t1;
262262#
263263# MDEV-6396: ANALYZE INSERT/REPLACE is accepted, but does not produce a plan
@@ -283,15 +283,15 @@ create table t1(a int);
283283insert into t1 values (1),(2);
284284analyze select a from t1 where a <2 into @var;
285285id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
286- 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2 100.00 50.00 Using where
286+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2.00 100.00 50.00 Using where
287287analyze select a from t1 into @var;
288288ERROR 42000: Result consisted of more than one row
289289analyze insert into t1 select * from t1;
290290id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
291- 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2 100.00 100.00 Using temporary
291+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2.00 100.00 100.00 Using temporary
292292analyze select * into outfile '../../tmp/data1.tmp' from t1;
293293id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
294- 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4 100.00 100.00
294+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
295295drop table t1;
296296#
297297# MDEV-7024: Assertion `! is_set()' failed in
@@ -303,3 +303,15 @@ execute stmt;
303303id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
3043041 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
305305drop table t1;
306+ #
307+ # MDEV-7674: ANALYZE shows r_rows=0
308+ #
309+ create table t1(a int);
310+ insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
311+ create table t2 (a int, key(a));
312+ insert into t2 values (0),(1);
313+ analyze select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
314+ id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
315+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00 Using where
316+ 1 SIMPLE t2 ref a a 5 test.t1.a 2 0.20 100.00 100.00 Using index
317+ drop table t1,t2;
0 commit comments