Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8c79e090
Commit
8c79e090
authored
Oct 05, 2019
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fix to tests
parent
30a63d6e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
223 additions
and
226 deletions
+223
-226
mysql-test/main/sort_nest.result
mysql-test/main/sort_nest.result
+3
-3
mysql-test/main/sort_nest.test
mysql-test/main/sort_nest.test
+165
-132
mysql-test/main/sort_nest_index.result
mysql-test/main/sort_nest_index.result
+15
-51
mysql-test/main/sort_nest_index.test
mysql-test/main/sort_nest_index.test
+40
-40
No files found.
mysql-test/main/sort_nest.result
View file @
8c79e090
...
...
@@ -1617,7 +1617,7 @@ x b b a
6 4 4 4
DROP TABLE t0,t1,t2,t3;
#
# Const table should not form the sort-nest
# Const table
s
should not form the sort-nest
#
CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY);
CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY);
...
...
@@ -1775,7 +1775,7 @@ CREATE TABLE t2 as SELECT * from t1;
set use_sort_nest=1;
EXPLAIN SELECT *
FROM t1,t2
WHERE t1.a=t2.a and t1.b= 4
WHERE t1.a=t2.a and t1.b= 4
ORDER BY t1.b DESC
LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
...
...
@@ -1783,7 +1783,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 10 Using where
SELECT *
FROM t1,t2
WHERE t1.a=t2.a and t1.b= 4
WHERE t1.a=t2.a and t1.b= 4
ORDER BY t1.b DESC
LIMIT 5;
a b a b
...
...
mysql-test/main/sort_nest.test
View file @
8c79e090
This diff is collapsed.
Click to expand it.
mysql-test/main/sort_nest_index.result
View file @
8c79e090
...
...
@@ -64,48 +64,30 @@ INSERT INTO t1 VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d');
# Should use index condition
#
set use_sort_nest= 1;
SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
a b
1 a
2 b
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
set use_sort_nest= 0;
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
#
# Should not use index condition as ORDER by DESC is used
#
set use_sort_nest= 1;
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
a b
2 b
1 a
set use_sort_nest= 0;
EXPLAIN SELECT * FROM t1
WHERE a BETWEEN 1 and 2
ORDER BY a DESC
LIMIT 2;
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN 1 and 2 ORDER BY a DESC LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
drop table t1;
...
...
@@ -123,9 +105,7 @@ insert into t2 select a, b, c from t1;
# Using range scan
#
set use_sort_nest= 1;
SELECT *
FROM
t1,t2
SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
...
...
@@ -133,9 +113,7 @@ ORDER BY t1.b LIMIT 10;
a b c a b c
2 9 3 2 9 3
2 10 4 2 10 4
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
...
...
@@ -144,9 +122,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a,a_b a_b 10 NULL 2 Using index condition
1 SIMPLE t2 ref b b 5 test.t1.b 1
set use_sort_nest= 0;
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.b > 8 AND
t1.b=t2.b
...
...
@@ -158,9 +134,7 @@ id select_type table type possible_keys key key_len ref rows Extra
# Using ref access
#
set use_sort_nest= 1;
SELECT *
FROM
t1,t2
SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
...
...
@@ -169,9 +143,7 @@ a b c a b c
2 8 2 2 8 2
2 9 3 2 9 3
2 10 4 2 10 4
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
...
...
@@ -180,9 +152,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a,a_b a_b 5 const 3 Using index condition; Using where
1 SIMPLE t2 ref b,c b 5 test.t1.b 1 Using where
set use_sort_nest= 0;
EXPLAIN SELECT *
FROM
t1,t2
EXPLAIN SELECT * FROM t1,t2
WHERE
t1.a=2 AND t2.c >= 1 AND
t1.b=t2.b
...
...
@@ -217,21 +187,15 @@ id select_type table type possible_keys key key_len ref rows Extra
# Index idx2 to be used for index scan(USE INDEX is used)
#
set use_sort_nest=1;
SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
a b c
1 1 1
2 2 2
EXPLAIN SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
EXPLAIN SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx2 10 NULL 2 Using where
set use_sort_nest=0;
EXPLAIN SELECT * from t1 USE INDEX(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2;
EXPLAIN SELECT * from t1 USE INDEX(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx2 10 NULL 2 Using where
#
...
...
mysql-test/main/sort_nest_index.test
View file @
8c79e090
...
...
@@ -56,10 +56,7 @@ INSERT INTO t1 VALUES (1,'a'), (2,'b'), (3,'c'), (4,'d');
--
echo
# Should use index condition
--
echo
#
let
$query
=
SELECT
*
FROM
t1
WHERE
a
BETWEEN
1
and
2
ORDER
BY
a
LIMIT
2
;
let
$query
=
SELECT
*
FROM
t1
WHERE
a
BETWEEN
1
and
2
ORDER
BY
a
LIMIT
2
;
set
use_sort_nest
=
1
;
eval
$query
;
...
...
@@ -72,10 +69,7 @@ eval EXPLAIN $query;
--
echo
# Should not use index condition as ORDER by DESC is used
--
echo
#
let
$query
=
SELECT
*
FROM
t1
WHERE
a
BETWEEN
1
and
2
ORDER
BY
a
DESC
LIMIT
2
;
let
$query
=
SELECT
*
FROM
t1
WHERE
a
BETWEEN
1
and
2
ORDER
BY
a
DESC
LIMIT
2
;
set
use_sort_nest
=
1
;
eval
EXPLAIN
$query
;
...
...
@@ -102,13 +96,13 @@ insert into t2 select a, b, c from t1;
--
echo
#
--
echo
# Using range scan
--
echo
#
let
$query
=
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
a
=
2
AND
t2
.
b
>
8
AND
t1
.
b
=
t2
.
b
ORDER
BY
t1
.
b
LIMIT
10
;
let
$query
=
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
a
=
2
AND
t2
.
b
>
8
AND
t1
.
b
=
t2
.
b
ORDER
BY
t1
.
b
LIMIT
10
;
set
use_sort_nest
=
1
;
eval
$query
;
...
...
@@ -120,13 +114,12 @@ eval EXPLAIN $query;
--
echo
#
--
echo
# Using ref access
--
echo
#
let
$query
=
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
a
=
2
AND
t2
.
c
>=
1
AND
t1
.
b
=
t2
.
b
ORDER
BY
t1
.
b
LIMIT
10
;
let
$query
=
SELECT
*
FROM
t1
,
t2
WHERE
t1
.
a
=
2
AND
t2
.
c
>=
1
AND
t1
.
b
=
t2
.
b
ORDER
BY
t1
.
b
LIMIT
10
;
set
use_sort_nest
=
1
;
eval
$query
;
...
...
@@ -165,9 +158,7 @@ eval EXPLAIN $query;
--
echo
# Index idx2 to be used for index scan(USE INDEX is used)
--
echo
#
let
$query
=
SELECT
*
from
t1
USE
INDEX
(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2
;
let
$query
=
SELECT
*
from
t1
USE
INDEX
(idx2) WHERE b > 0 ORDER BY t1.a LIMIT 2
;
set
use_sort_nest
=
1
;
eval
$query
;
eval
EXPLAIN
$query
;
...
...
@@ -179,9 +170,11 @@ eval EXPLAIN $query;
--
echo
# Index idx2 to be used for index scan(USE INDEX for ORDER BY is used)
--
echo
#
let
$query
=
SELECT
*
from
t1
USE
INDEX
FOR ORDER BY(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2
;
let
$query
=
SELECT
*
from
t1
USE
INDEX
FOR ORDER BY(idx2)
WHERE b > 0
ORDER BY t1.a LIMIT 2
;
set
use_sort_nest
=
1
;
eval
$query
;
eval
EXPLAIN
$query
;
...
...
@@ -193,9 +186,11 @@ eval EXPLAIN $query;
--
echo
# Use Filesort as idx3 does not resolve ORDER BY clause
--
echo
#
let
$query
=
SELECT
*
from
t1
USE
INDEX
FOR ORDER BY(idx3)
WHERE b > 0
ORDER BY t1.a LIMIT 2
;
let
$query
=
SELECT
*
from
t1
USE
INDEX
FOR ORDER BY(idx3)
WHERE b > 0
ORDER BY t1.a LIMIT 2
;
set
use_sort_nest
=
1
;
eval
$query
;
eval
EXPLAIN
$query
;
...
...
@@ -207,9 +202,11 @@ eval EXPLAIN $query;
--
echo
# Using index idx2 as idx1 is ignored
--
echo
#
let
$query
=
SELECT
*
from
t1
IGNORE
INDEX
(
idx1
)
WHERE
b
>
0
ORDER
BY
t1
.
a
LIMIT
2
;
let
$query
=
SELECT
*
from
t1
IGNORE
INDEX
(
idx1
)
WHERE
b
>
0
ORDER
BY
t1
.
a
LIMIT
2
;
set
use_sort_nest
=
1
;
eval
$query
;
eval
EXPLAIN
$query
;
...
...
@@ -221,9 +218,11 @@ eval EXPLAIN $query;
--
echo
# Use index idx2 for sorting, it is forced here
--
echo
#
let
$query
=
SELECT
*
from
t1
FORCE
INDEX
(
idx2
)
WHERE
b
>
0
ORDER
BY
t1
.
a
LIMIT
2
;
let
$query
=
SELECT
*
from
t1
FORCE
INDEX
(
idx2
)
WHERE
b
>
0
ORDER
BY
t1
.
a
LIMIT
2
;
set
use_sort_nest
=
1
;
eval
$query
;
eval
EXPLAIN
$query
;
...
...
@@ -235,9 +234,10 @@ eval EXPLAIN $query;
--
echo
# Use FILESORT as idx3 cannot resolve ORDER BY clause
--
echo
#
let
$query
=
SELECT
*
from
t1
FORCE
INDEX
FOR
ORDER
BY
(
idx3
)
WHERE
b
>
0
ORDER
BY
t1
.
a
LIMIT
2
;
let
$query
=
SELECT
*
from
t1
FORCE
INDEX
FOR
ORDER
BY
(
idx3
)
WHERE
b
>
0
ORDER
BY
t1
.
a
LIMIT
2
;
set
use_sort_nest
=
1
;
eval
$query
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment