From 3bb249612fe3864f152aa990d4d5f267ac9bb688 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 20 Mar 2014 23:27:08 +0100 Subject: MDEV-5846 MySQL Bug #18144 - Cost with FORCE/USE index seems incorrect in some cases. --- mysql-test/t/key.test | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mysql-test/t/key.test') diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 9a4158d8e13..355c5ef53a4 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -561,3 +561,23 @@ SELECT 1 as RES FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; DROP TABLE t1; + +--echo # +--echo # Bug#18144: Cost with FORCE/USE index seems incorrect in some cases. +--echo # +--echo # We are interested in showing that the cost for the last plan is higher +--echo # than for the preceding two plans. +--echo # +CREATE TABLE t1( a INT, b INT, KEY( a ) ); +INSERT INTO t1 values (1, 2), (1, 3), (2, 3), (2, 4), (3, 4), (3, 5); + +EXPLAIN SELECT a, SUM( b ) FROM t1 GROUP BY a; +SHOW STATUS LIKE 'Last_query_cost'; + +EXPLAIN SELECT a, SUM( b ) FROM t1 USE INDEX( a ) GROUP BY a; +SHOW STATUS LIKE 'Last_query_cost'; + +EXPLAIN SELECT a, SUM( b ) FROM t1 FORCE INDEX( a ) GROUP BY a; +SHOW STATUS LIKE 'Last_query_cost'; + +DROP TABLE t1; -- cgit v1.2.1