root@localhost [test]> system cat docs/INFO_SRC commit: 432d360adedd7d8976fd6254eb3f5bee0b1ac3d6 date: 2017-06-22 16:12:22 +0200 build-date: 2017-06-22 16:13:32 +0200 short: 432d360 branch: mysql-5.7.19-release MySQL source 5.7.19 [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.19: wget -O t2.sql https://bugs.mysql.com/file.php?id=25953&bug_id=87947 [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.19: bin/mysql -uroot -S /tmp/mysql_ushastry.sock test < t2.sql SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 SLEEP(1) 0 [umshastr@hod03]/export/umesh/server/binaries/GABuilds/mysql-5.7.19: bin/mysql -uroot -S /tmp/mysql_ushastry.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.19-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@localhost [(none)]> use test Database changed root@localhost [test]> SELECT @a:=TIMESTAMPADD(SECOND,3,MIN(b)), @b:=TIMESTAMPADD(SECOND,3,MIN(b)) FROM t2; +-----------------------------------+-----------------------------------+ | @a:=TIMESTAMPADD(SECOND,3,MIN(b)) | @b:=TIMESTAMPADD(SECOND,3,MIN(b)) | +-----------------------------------+-----------------------------------+ | 2017-10-09 07:24:16 | 2017-10-09 07:24:16 | +-----------------------------------+-----------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> SELECT @b:=TIMESTAMPADD(SECOND,1,@b); +-------------------------------+ | @b:=TIMESTAMPADD(SECOND,1,@b) | +-------------------------------+ | 2017-10-09 07:24:17 | +-------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> EXPLAIN SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | 1 | SIMPLE | t2 | NULL | range | b,c | b | 4 | NULL | 48 | 49.81 | Using index condition; Using where | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ 1 row in set, 1 warning (0.00 sec) root@localhost [test]> SELECT @b:=TIMESTAMPADD(SECOND,1,@b); +-------------------------------+ | @b:=TIMESTAMPADD(SECOND,1,@b) | +-------------------------------+ | 2017-10-09 07:24:18 | +-------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> EXPLAIN SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | 1 | SIMPLE | t2 | NULL | range | b,c | b | 4 | NULL | 112 | 49.81 | Using index condition; Using where | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ 1 row in set, 1 warning (0.00 sec) root@localhost [test]> SELECT @b:=TIMESTAMPADD(SECOND,1,@b); +-------------------------------+ | @b:=TIMESTAMPADD(SECOND,1,@b) | +-------------------------------+ | 2017-10-09 07:24:19 | +-------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> EXPLAIN SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | 1 | SIMPLE | t2 | NULL | range | b,c | b | 4 | NULL | 240 | 49.81 | Using index condition; Using where | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ 1 row in set, 1 warning (0.00 sec) root@localhost [test]> SELECT @b:=TIMESTAMPADD(SECOND,1,@b); +-------------------------------+ | @b:=TIMESTAMPADD(SECOND,1,@b) | +-------------------------------+ | 2017-10-09 07:24:20 | +-------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> EXPLAIN SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | 1 | SIMPLE | t2 | NULL | range | b,c | b | 4 | NULL | 496 | 49.81 | Using index condition; Using where | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ 1 row in set, 1 warning (0.00 sec) root@localhost [test]> SELECT @b:=TIMESTAMPADD(SECOND,1,@b); +-------------------------------+ | @b:=TIMESTAMPADD(SECOND,1,@b) | +-------------------------------+ | 2017-10-09 07:24:21 | +-------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> EXPLAIN SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ | 1 | SIMPLE | t2 | NULL | range | b,c | b | 4 | NULL | 1008 | 49.81 | Using index condition; Using where | +----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+------------------------------------+ 1 row in set, 1 warning (0.00 sec) root@localhost [test]> SELECT @b:=TIMESTAMPADD(SECOND,1,@b); +-------------------------------+ | @b:=TIMESTAMPADD(SECOND,1,@b) | +-------------------------------+ | 2017-10-09 07:24:22 | +-------------------------------+ 1 row in set (0.00 sec) root@localhost [test]> EXPLAIN SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+ | 1 | SIMPLE | t2 | NULL | ref | b,c | c | 5 | const | 8192 | 12.36 | Using where | +----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+ 1 row in set, 1 warning (0.00 sec) root@localhost [test]> SET PROFILING=1; Query OK, 0 rows affected, 1 warning (0.00 sec) root@localhost [test]> SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.02 sec) root@localhost [test]> SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.02 sec) root@localhost [test]> SELECT count(*) FROM t2 USE INDEX(b) WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.01 sec) root@localhost [test]> SELECT count(*) FROM t2 USE INDEX(b) WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.01 sec) root@localhost [test]> SELECT count(*) FROM t2 USE INDEX(b) WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.01 sec) root@localhost [test]> SELECT count(*) FROM t2 USE INDEX(c) WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.02 sec) root@localhost [test]> SELECT count(*) FROM t2 USE INDEX(c) WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.02 sec) root@localhost [test]> SELECT count(*) FROM t2 USE INDEX(c) WHERE b BETWEEN @a AND @b and c=1; +----------+ | count(*) | +----------+ | 1016 | +----------+ 1 row in set (0.02 sec) root@localhost [test]> SHOW PROFILES; +----------+------------+------------------------------------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+------------------------------------------------------------------------+ | 1 | 0.02068525 | SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1 | | 2 | 0.01881450 | SELECT count(*) FROM t2 WHERE b BETWEEN @a AND @b and c=1 | | 3 | 0.00676325 | SELECT count(*) FROM t2 USE INDEX(b) WHERE b BETWEEN @a AND @b and c=1 | | 4 | 0.00660050 | SELECT count(*) FROM t2 USE INDEX(b) WHERE b BETWEEN @a AND @b and c=1 | | 5 | 0.00669725 | SELECT count(*) FROM t2 USE INDEX(b) WHERE b BETWEEN @a AND @b and c=1 | | 6 | 0.01884250 | SELECT count(*) FROM t2 USE INDEX(c) WHERE b BETWEEN @a AND @b and c=1 | | 7 | 0.01862300 | SELECT count(*) FROM t2 USE INDEX(c) WHERE b BETWEEN @a AND @b and c=1 | | 8 | 0.01839775 | SELECT count(*) FROM t2 USE INDEX(c) WHERE b BETWEEN @a AND @b and c=1 | +----------+------------+------------------------------------------------------------------------+ 8 rows in set, 1 warning (0.00 sec) root@localhost [test]>