Debian Codegraph @

mysql-test/suite/parts/r/optimizer.result

raw
1 drop table if exists t1,t2;
2 #
3 # Bug#50939: Loose Index Scan unduly relies on engine to remember range
4 # endpoints
5 #
6 CREATE TABLE t1 (
7 a INT,
8 b INT,
9 KEY ( a, b )
10 ) PARTITION BY HASH (a) PARTITIONS 1;
11 CREATE TABLE t2 (
12 a INT,
13 b INT,
14 KEY ( a, b )
15 );
16 INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
17 INSERT INTO t1 SELECT a + 5, b + 5 FROM t1;
18 INSERT INTO t1 SELECT a + 10, b + 10 FROM t1;
19 INSERT INTO t1 SELECT a + 20, b + 20 FROM t1;
20 INSERT INTO t1 SELECT a + 40, b + 40 FROM t1;
21 INSERT INTO t2 SELECT * FROM t1;
22 # plans should be identical
23 EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a;
24 id select_type table type possible_keys key key_len ref rows Extra
25 1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index for group-by
26 EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
27 id select_type table type possible_keys key key_len ref rows Extra
28 1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by
29 FLUSH status;
30 SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a;
31 a MAX(b)
32 10 10
33 # Should be no more than 4 reads.
34 SHOW status LIKE 'handler_read_key';
35 Variable_name Value
36 Handler_read_key 4
37 FLUSH status;
38 SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a;
39 a MAX(b)
40 10 10
41 # Should be no more than 4 reads.
42 SHOW status LIKE 'handler_read_key';
43 Variable_name Value
44 Handler_read_key 4
45 DROP TABLE t1, t2;