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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d18df32b
Commit
d18df32b
authored
Sep 28, 2007
by
mhansson@dl145s.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mhansson@bk-internal:/home/bk/mysql-5.1-opt
into dl145s.mysql.com:/data0/mhansson/my51-bug30665
parents
ca2c93fc
ab73b25d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
493 additions
and
2 deletions
+493
-2
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+147
-1
mysql-test/r/order_by.result
mysql-test/r/order_by.result
+285
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+1
-0
mysql-test/t/order_by.test
mysql-test/t/order_by.test
+57
-0
sql/sql_select.cc
sql/sql_select.cc
+3
-1
No files found.
mysql-test/r/group_by.result
View file @
d18df32b
...
@@ -1096,7 +1096,153 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1096,7 +1096,153 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY)
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY)
IGNORE INDEX FOR GROUP BY (i2) GROUP BY a;
IGNORE INDEX FOR GROUP BY (i2) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
...
...
mysql-test/r/order_by.result
View file @
d18df32b
...
@@ -1131,3 +1131,288 @@ id c3
...
@@ -1131,3 +1131,288 @@ id c3
186 14
186 14
196 14
196 14
DROP TABLE t1,t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (
a INT,
b INT,
PRIMARY KEY (a),
KEY ab(a, b)
);
INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4);
INSERT INTO t1 SELECT a + 4, b + 4 FROM t1;
INSERT INTO t1 SELECT a + 8, b + 8 FROM t1;
INSERT INTO t1 SELECT a +16, b +16 FROM t1;
INSERT INTO t1 SELECT a +32, b +32 FROM t1;
INSERT INTO t1 SELECT a +64, b +64 FROM t1;
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL ab 4 NULL 10 Using index for group-by
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
SELECT @tmp_tables_after = @tmp_tables_before ;
@tmp_tables_after = @tmp_tables_before
1
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using index
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
SELECT @tmp_tables_after = @tmp_tables_before;
@tmp_tables_after = @tmp_tables_before
1
DROP TABLE t1;
mysql-test/t/group_by.test
View file @
d18df32b
...
@@ -811,6 +811,7 @@ EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2);
...
@@ -811,6 +811,7 @@ EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2);
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
JOIN
(
PRIMARY
,
i2
);
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
JOIN
(
PRIMARY
,
i2
);
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
GROUP
BY
(
PRIMARY
,
i2
)
GROUP
BY
a
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
GROUP
BY
(
PRIMARY
,
i2
)
GROUP
BY
a
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
PRIMARY
,
i2
)
ORDER
BY
a
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
PRIMARY
,
i2
)
ORDER
BY
a
;
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
PRIMARY
,
i2
)
ORDER
BY
a
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
PRIMARY
)
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
PRIMARY
)
IGNORE
INDEX
FOR
GROUP
BY
(
i2
)
GROUP
BY
a
;
IGNORE
INDEX
FOR
GROUP
BY
(
i2
)
GROUP
BY
a
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
(
PRIMARY
)
IGNORE
INDEX
FOR
ORDER
BY
(
i2
);
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
(
PRIMARY
)
IGNORE
INDEX
FOR
ORDER
BY
(
i2
);
...
...
mysql-test/t/order_by.test
View file @
d18df32b
...
@@ -779,3 +779,60 @@ EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000;
...
@@ -779,3 +779,60 @@ EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000;
SELECT
id
,
c3
FROM
t2
WHERE
c2
=
11
ORDER
BY
c3
LIMIT
20
;
SELECT
id
,
c3
FROM
t2
WHERE
c2
=
11
ORDER
BY
c3
LIMIT
20
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
#
# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY}
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
,
PRIMARY
KEY
(
a
),
KEY
ab
(
a
,
b
)
);
INSERT
INTO
t1
VALUES
(
1
,
1
),(
2
,
2
),(
3
,
3
),(
4
,
4
);
INSERT
INTO
t1
SELECT
a
+
4
,
b
+
4
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
8
,
b
+
8
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
16
,
b
+
16
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
32
,
b
+
32
FROM
t1
;
INSERT
INTO
t1
SELECT
a
+
64
,
b
+
64
FROM
t1
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
GROUP
BY
(
a
,
ab
)
GROUP
BY
a
;
--
disable_query_log
--
let
$q
=
`show status like 'Created_tmp_tables';`
eval
set
@
tmp_tables_before
=
CAST
(
REPLACE
(
'$q'
,
'Created_tmp_tables'
,
''
)
AS
UNSIGNED
);
--
enable_query_log
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
GROUP
BY
(
a
,
ab
)
GROUP
BY
a
;
# this query creates one temporary table in itself, which we are not
# interested in.
--
disable_query_log
--
let
$q
=
`show status like 'Created_tmp_tables';`
eval
set
@
tmp_tables_after
=
CAST
(
REPLACE
(
'$q'
,
'Created_tmp_tables'
,
''
)
AS
UNSIGNED
);
--
enable_query_log
SELECT
@
tmp_tables_after
=
@
tmp_tables_before
;
EXPLAIN
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
a
,
ab
)
ORDER
BY
a
;
--
disable_query_log
--
let
$q
=
`show status like 'Created_tmp_tables';`
eval
set
@
tmp_tables_before
=
CAST
(
REPLACE
(
'$q'
,
'Created_tmp_tables'
,
''
)
AS
UNSIGNED
);
--
enable_query_log
SELECT
a
FROM
t1
IGNORE
INDEX
FOR
ORDER
BY
(
a
,
ab
)
ORDER
BY
a
;
--
disable_query_log
--
let
$q
=
`show status like 'Created_tmp_tables';`
eval
set
@
tmp_tables_after
=
CAST
(
REPLACE
(
'$q'
,
'Created_tmp_tables'
,
''
)
AS
UNSIGNED
);
--
enable_query_log
SELECT
@
tmp_tables_after
=
@
tmp_tables_before
;
DROP
TABLE
t1
;
sql/sql_select.cc
View file @
d18df32b
...
@@ -1695,7 +1695,7 @@ JOIN::exec()
...
@@ -1695,7 +1695,7 @@ JOIN::exec()
test_if_skip_sort_order
(
&
join_tab
[
const_tables
],
order
,
test_if_skip_sort_order
(
&
join_tab
[
const_tables
],
order
,
select_limit
,
0
,
select_limit
,
0
,
&
join_tab
[
const_tables
].
table
->
&
join_tab
[
const_tables
].
table
->
keys_in_use_for_
order_b
y
))))
keys_in_use_for_
quer
y
))))
order
=
0
;
order
=
0
;
having
=
tmp_having
;
having
=
tmp_having
;
select_describe
(
this
,
need_tmp
,
select_describe
(
this
,
need_tmp
,
...
@@ -12614,6 +12614,8 @@ find_field_in_item_list (Field *field, void *data)
...
@@ -12614,6 +12614,8 @@ find_field_in_item_list (Field *field, void *data)
If we can use an index, the JOIN_TAB / tab->select struct
If we can use an index, the JOIN_TAB / tab->select struct
is changed to use the index.
is changed to use the index.
The index must cover all fields in <order>, or it will not be considered.
Return:
Return:
0 We have to use filesort to do the sorting
0 We have to use filesort to do the sorting
1 We can use an index.
1 We can use an index.
...
...
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