summaryrefslogtreecommitdiff
path: root/mysql-test/t/join.test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-10-05 17:28:34 +0300
committerunknown <gkodinov/kgeorge@magare.gmz>2007-10-05 17:28:34 +0300
commit10cde5e4b1c8716c8e76259041b35456795f6906 (patch)
tree95dd19af11e1dc3bca25d0a65b698bef67e312e1 /mysql-test/t/join.test
parent7e5f4fe24b0fcd8801cd3d8c0d0968c6e9431dc2 (diff)
downloadmariadb-git-10cde5e4b1c8716c8e76259041b35456795f6906.tar.gz
Bug #31094: Forcing index-based sort doesn't work anymore if joins are done
A rule was introduced by the 5.1 part of the fix for bug 27531 to prefer filesort over indexed ORDER BY when accessing all of the rows of a table (because it's faster). This new rule was not accounting for the presence of a LIMIT clause. Fixed the condition for this rule so it will prefer filesort over indexed ORDER BY only if no LIMIT. mysql-test/r/compress.result: Bug #31094: LIMIT is not considered a full index scan mysql-test/r/join.result: Bug #31094: test case mysql-test/r/select.result: Bug #31094: LIMIT is not considered a full index scan mysql-test/r/ssl.result: Bug #31094: LIMIT is not considered a full index scan mysql-test/r/ssl_compress.result: Bug #31094: LIMIT is not considered a full index scan mysql-test/t/join.test: Bug #31094: test case sql/sql_select.cc: Bug #31094: prefer filesort over indexed ORDER BY only if no LIMIT
Diffstat (limited to 'mysql-test/t/join.test')
-rw-r--r--mysql-test/t/join.test29
1 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 14c98431970..ed1b84bb5ec 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -698,4 +698,33 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than
drop table t1, t2;
+#
+# Bug #31094: Forcing index-based sort doesn't work anymore if joins are
+# done
+#
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
+CREATE TABLE t2 (c INT PRIMARY KEY, d INT);
+
+INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL);
+INSERT INTO t1 SELECT a + 4, b FROM t1;
+INSERT INTO t1 SELECT a + 8, b FROM t1;
+INSERT INTO t1 SELECT a + 16, b FROM t1;
+INSERT INTO t1 SELECT a + 32, b FROM t1;
+INSERT INTO t1 SELECT a + 64, b FROM t1;
+INSERT INTO t2 SELECT a, b FROM t1;
+
+#expect indexed ORDER BY
+EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2;
+EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2;
+SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2;
+SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2;
+
+#expect filesort
+EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a;
+EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a;
+SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a;
+SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a;
+
+DROP TABLE IF EXISTS t1,t2;
--echo End of 5.0 tests.