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
6025d0ba
Commit
6025d0ba
authored
Feb 26, 2010
by
Evgeny Potemkin
Browse files
Options
Browse Files
Download
Plain Diff
Auto-merged fox for the bug#50843.
parents
936ed6ca
2d4db52e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
6 deletions
+39
-6
mysql-test/r/innodb_mysql.result
mysql-test/r/innodb_mysql.result
+14
-0
mysql-test/t/innodb_mysql.test
mysql-test/t/innodb_mysql.test
+12
-0
sql/sql_select.cc
sql/sql_select.cc
+13
-6
No files found.
mysql-test/r/innodb_mysql.result
View file @
6025d0ba
...
@@ -2281,4 +2281,18 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
...
@@ -2281,4 +2281,18 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a;
1
1
DROP TABLE t1;
DROP TABLE t1;
#
# Bug#50843: Filesort used instead of clustered index led to
# performance degradation.
#
create table t1(f1 int not null primary key, f2 int) engine=innodb;
create table t2(f1 int not null, key (f1)) engine=innodb;
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1),(2),(3);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 3
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 1 Using index
drop table t1,t2;
#
End of 5.1 tests
End of 5.1 tests
mysql-test/t/innodb_mysql.test
View file @
6025d0ba
...
@@ -545,5 +545,17 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
...
@@ -545,5 +545,17 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ;
SELECT
1
FROM
t1
JOIN
t1
a
USING
(
a
)
GROUP
BY
t1
.
a
,
t1
.
a
;
SELECT
1
FROM
t1
JOIN
t1
a
USING
(
a
)
GROUP
BY
t1
.
a
,
t1
.
a
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Bug#50843: Filesort used instead of clustered index led to
--
echo
# performance degradation.
--
echo
#
create
table
t1
(
f1
int
not
null
primary
key
,
f2
int
)
engine
=
innodb
;
create
table
t2
(
f1
int
not
null
,
key
(
f1
))
engine
=
innodb
;
insert
into
t1
values
(
1
,
1
),(
2
,
2
),(
3
,
3
);
insert
into
t2
values
(
1
),(
2
),(
3
);
explain
select
t1
.*
from
t1
left
join
t2
using
(
f1
)
group
by
t1
.
f1
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
End
of
5.1
tests
--
echo
End
of
5.1
tests
sql/sql_select.cc
View file @
6025d0ba
...
@@ -13306,12 +13306,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
...
@@ -13306,12 +13306,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
*/
if
(
select_limit
>=
table_records
)
if
(
select_limit
>=
table_records
)
{
{
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache
*/
if
(
tab
->
type
==
JT_ALL
&&
tab
->
join
->
tables
>
tab
->
join
->
const_tables
+
1
)
DBUG_RETURN
(
0
);
keys
=
*
table
->
file
->
keys_to_use_for_scanning
();
keys
=
*
table
->
file
->
keys_to_use_for_scanning
();
keys
.
merge
(
table
->
covering_keys
);
keys
.
merge
(
table
->
covering_keys
);
...
@@ -13461,6 +13455,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
...
@@ -13461,6 +13455,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
}
}
}
}
}
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache, except in case that chosen
index is clustered primary key.
*/
if
((
select_limit
>=
table_records
)
&&
(
tab
->
type
==
JT_ALL
&&
tab
->
join
->
tables
>
tab
->
join
->
const_tables
+
1
)
&&
((
unsigned
)
best_key
!=
table
->
s
->
primary_key
||
!
table
->
file
->
primary_key_is_clustered
()))
DBUG_RETURN
(
0
);
if
(
best_key
>=
0
)
if
(
best_key
>=
0
)
{
{
bool
quick_created
=
FALSE
;
bool
quick_created
=
FALSE
;
...
...
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