Skip to content

Commit 66ad265

Browse files
committed
MDEV-7674: ANALYZE shows r_rows=0
Change r_rows to be double
1 parent 143f5d9 commit 66ad265

File tree

8 files changed

+142
-66
lines changed

8 files changed

+142
-66
lines changed

mysql-test/r/analyze_format_json.result

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ insert into t1 select A.a*10 + B.a, A.a*10 + B.a, A.a*10 + B.a from t0 A, t0 B;
2424
analyze
2525
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
2626
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
27-
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 0.00 Using where
27+
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00100.00 0.00 Using where
2828
1 SIMPLE t1 ref a a 5 test.t0.a 1 NULL 100.00 NULL
2929
analyze format=json
3030
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
@@ -61,8 +61,8 @@ EXPLAIN
6161
analyze
6262
select * from t0, t1 where t1.a=t0.a and t1.b<4;
6363
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
64-
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10 100.00 100.00 Using where
65-
1 SIMPLE t1 ref a a 5 test.t0.a 1 1 100.00 40.00 Using where
64+
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 10.00100.00 100.00 Using where
65+
1 SIMPLE t1 ref a a 5 test.t0.a 1 1.00100.00 40.00 Using where
6666
analyze format=json
6767
select * from t0, t1 where t1.a=t0.a and t1.b<4;
6868
EXPLAIN
@@ -99,8 +99,8 @@ EXPLAIN
9999
analyze
100100
select * from t1 tbl1, t1 tbl2 where tbl1.b<2 and tbl2.b>5;
101101
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
102-
1 SIMPLE tbl1 ALL NULL NULL NULL NULL 100 100 100.00 2.00 Using where
103-
1 SIMPLE tbl2 ALL NULL NULL NULL NULL 100 100 100.00 94.00 Using where; Using join buffer (flat, BNL join)
102+
1 SIMPLE tbl1 ALL NULL NULL NULL NULL 100 100.00100.00 2.00 Using where
103+
1 SIMPLE tbl2 ALL NULL NULL NULL NULL 100 100.00100.00 94.00 Using where; Using join buffer (flat, BNL join)
104104
analyze format=json
105105
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60;
106106
EXPLAIN
@@ -170,3 +170,43 @@ EXPLAIN
170170
}
171171
drop table t1;
172172
drop table t0;
173+
#
174+
# MDEV-7674: ANALYZE shows r_rows=0
175+
#
176+
create table t1(a int);
177+
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
178+
create table t2 (a int, key(a));
179+
insert into t2 values (0),(1);
180+
analyze format=json select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
181+
EXPLAIN
182+
{
183+
"query_block": {
184+
"select_id": 1,
185+
"table": {
186+
"table_name": "t1",
187+
"access_type": "ALL",
188+
"r_loops": 1,
189+
"rows": 10,
190+
"r_rows": 10,
191+
"filtered": 100,
192+
"r_filtered": 100,
193+
"attached_condition": "(t1.a is not null)"
194+
},
195+
"table": {
196+
"table_name": "t2",
197+
"access_type": "ref",
198+
"possible_keys": ["a"],
199+
"key": "a",
200+
"key_length": "5",
201+
"used_key_parts": ["a"],
202+
"ref": ["test.t1.a"],
203+
"r_loops": 10,
204+
"rows": 2,
205+
"r_rows": 0.2,
206+
"filtered": 100,
207+
"r_filtered": 100,
208+
"using_index": true
209+
}
210+
}
211+
}
212+
drop table t1,t2;

mysql-test/r/analyze_stmt.result

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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
77
analyze select * from t1;
88
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
9+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 100.00
1010
analyze select * from t1 where a<5;
1111
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
12+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 50.00 Using where
1313
analyze select * from t1 where a>100;
1414
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
15+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 0.00 Using where
1616
# ANALYZE DELETE will delete rows:
1717
analyze delete from t1 where a in (2,3,4);
1818
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 10 100.00 30.00 Using where
19+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 30.00 Using where
2020
select * from t1;
2121
a
2222
0
@@ -32,7 +32,7 @@ create table t1(a int, b int);
3232
insert into t1 select a,a from t0;
3333
analyze update t1 set b=100+b where a in (6,7,8);
3434
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 10 100.00 30.00 Using where
35+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 30.00 Using where
3636
select * from t1;
3737
a b
3838
0 0
@@ -51,14 +51,14 @@ create table t1(a int, b int);
5151
insert into t1 select a,a from t0;
5252
analyze (select * from t1 A where a<5) union (select * from t1 B where a in (5,6));
5353
id 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.00100.00 50.00 Using where
55+
2 UNION B ALL NULL NULL NULL NULL 10 10.00100.00 20.00 Using where
56+
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 7.00NULL NULL
5757
analyze (select * from t1 A where a<5) union (select * from t1 B where a in (1,2));
5858
id 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.00100.00 50.00 Using where
60+
2 UNION B ALL NULL NULL NULL NULL 10 10.00100.00 20.00 Using where
61+
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL 5.00NULL NULL
6262
drop table t1;
6363
drop 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.
7373
analyze select a, a in (select t0.b from t0 where t0.b+1=t1.b+1) from t1;
7474
id 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.00100.00 100.00
76+
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 3.00100.00 33.33 Using where
7777
# Try a subquery that is never executed
7878
analyze select a, a in (select t0.b from t0 where t0.b+1=t1.b+1) from t1 where t1.a > 5;
7979
id 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.00100.00 0.00 Using where
8181
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 NULL 100.00 NULL Using where
8282
drop 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
9696
analyze select * from t0, t1 where t0.a<5 and t1.a<5;
9797
id 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.00100.00 50.00 Using where
99+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 50.00 Using where; Using join buffer (flat, BNL join)
100100
explain select * from t0, t1 where t0.a<5 and t1.b=t0.b;
101101
id select_type table type possible_keys key key_len ref rows Extra
102102
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
103103
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
104104
# Now, t1 should have filtered=10
105105
analyze select * from t0, t1 where t0.a<5 and t1.b=t0.b;
106106
id 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.00100.00 50.00 Using where
108+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 10.00 Using where; Using join buffer (flat, BNL join)
109109
explain select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
110110
id select_type table type possible_keys key key_len ref rows Extra
111111
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
112112
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
113113
# Now, t1 should have filtered=10
114114
analyze select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
115115
id 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.00100.00 50.00 Using where
117+
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.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%.
128128
analyze select * from t1,t2 where t2.key1=t1.a;
129129
id 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.00100.00 100.00 Using where
131+
1 SIMPLE t2 ref key1 key1 5 test.t1.a 1 1.00100.00 100.00
132132
# This shows r_rows=0. It is actually 0.5 (should r_rows be changed to double?)
133133
analyze select * from t1,t2 where t2.key2x=t1.a;
134134
id 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.00100.00 100.00 Using where
136+
1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0.50100.00 100.00
137137
select * from t1,t2 where t2.key2x=t1.a;
138138
a b key1 key2x col1
139139
0 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)
145145
analyze select * from t1,t2 where t2.key2x=t1.a and mod(t2.col1,4)=0;
146146
id 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.00100.00 100.00 Using where
148+
1 SIMPLE t2 ref key2x key2x 5 test.t1.a 1 0.50100.00 40.00 Using where
149149
drop table t0,t1,t2;
150150
#
151151
# Check non-merged derived tables
@@ -156,8 +156,8 @@ insert into t0 values
156156
update t0 set b=b/3;
157157
analyze select * from (select count(*),max(a),b from t0 group by b) T;
158158
id 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.00100.00 100.00
160+
2 DERIVED t0 ALL NULL NULL NULL NULL 10 10.00100.00 100.00 Using temporary; Using filesort
161161
drop 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);
168168
analyze select count(*),max(a),b from t0 where a<7 group by b;
169169
id 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.00100.00 70.00 Using where; Using temporary; Using filesort
171171
drop 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);
178178
insert into t1 values (0,0),(2,2), (6,6);
179179
analyze select * from t0,t1 where t0.a=t1.a;
180180
id 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.00100.00 100.00
182+
1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4.00100.00 16.67 Using where; Using join buffer (flat, BNL join)
183183
analyze update t0,t1 set t1.b=5555 where t0.a=t1.a;
184184
id 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.00100.00 100.00
186+
1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4.00100.00 16.67 Using where
187187
select * from t1;
188188
a b
189189
0 5555
190190
2 5555
191191
6 6
192192
analyze delete t1 from t1, t0 where t0.a=t1.a;
193193
id 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.00100.00 100.00
195+
1 SIMPLE t0 ALL NULL NULL NULL NULL 4 4.00100.00 16.67 Using where
196196
select * from t1;
197197
a b
198198
6 6
@@ -240,7 +240,7 @@ create table t1 (i int);
240240
insert into t1 values (1),(2),(3),(4);
241241
analyze update t1 set i=8;
242242
id 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.00100.00 100.00
244244
drop table t1;
245245
#
246246
# Check ANALYZE SELECT INTO
@@ -257,7 +257,7 @@ drop table t1;
257257
create table t1 (i int);
258258
analyze delete from t1 returning *;
259259
id 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.00100.00 100.00
261261
drop 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);
283283
insert into t1 values (1),(2);
284284
analyze select a from t1 where a <2 into @var;
285285
id 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.00100.00 50.00 Using where
287287
analyze select a from t1 into @var;
288288
ERROR 42000: Result consisted of more than one row
289289
analyze insert into t1 select * from t1;
290290
id 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.00100.00 100.00 Using temporary
292292
analyze select * into outfile '../../tmp/data1.tmp' from t1;
293293
id 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.00100.00 100.00
295295
drop table t1;
296296
#
297297
# MDEV-7024: Assertion `! is_set()' failed in
@@ -303,3 +303,15 @@ execute stmt;
303303
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
304304
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
305305
drop 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;

mysql-test/r/analyze_stmt_slow_query_log.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ drop table t1;
1010
# explain: id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1111
# explain: 1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL 100.00 100.00 NULL
1212
# explain: id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
13-
# explain: 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 30.00 Using where
13+
# explain: 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00100.00 30.00 Using where
1414
# explain: id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1515
# explain: 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used

mysql-test/t/analyze_format_json.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,18 @@ select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60 and tbl1.c > tbl2.c
3636

3737
drop table t1;
3838
drop table t0;
39+
40+
--echo #
41+
--echo # MDEV-7674: ANALYZE shows r_rows=0
42+
--echo #
43+
44+
create table t1(a int);
45+
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
46+
47+
create table t2 (a int, key(a));
48+
insert into t2 values (0),(1);
49+
50+
analyze format=json select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
51+
52+
drop table t1,t2;
53+

mysql-test/t/analyze_stmt.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,18 @@ create table t1(a int);
244244
prepare stmt from "analyze select * from t1";
245245
execute stmt;
246246
drop table t1;
247+
248+
--echo #
249+
--echo # MDEV-7674: ANALYZE shows r_rows=0
250+
--echo #
251+
252+
create table t1(a int);
253+
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
254+
255+
create table t2 (a int, key(a));
256+
insert into t2 values (0),(1);
257+
258+
analyze select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
259+
260+
drop table t1,t2;
261+

sql/sql_class.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,8 +2454,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
24542454
MYSQL_TYPE_LONGLONG));
24552455
if (is_analyze)
24562456
{
2457-
field_list.push_back(item= new Item_return_int("r_rows", 10,
2458-
MYSQL_TYPE_LONGLONG));
2457+
field_list.push_back(item= new Item_float("r_rows", 0.1234, 10, 4));
24592458
item->maybe_null=1;
24602459
}
24612460

0 commit comments

Comments
 (0)