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
44b1d7be
Commit
44b1d7be
authored
Aug 15, 2024
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests
parent
3f65208c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
1 deletion
+110
-1
mysql-test/main/order_by_limit_join.result
mysql-test/main/order_by_limit_join.result
+83
-0
mysql-test/main/order_by_limit_join.test
mysql-test/main/order_by_limit_join.test
+27
-1
No files found.
mysql-test/main/order_by_limit_join.result
View file @
44b1d7be
...
...
@@ -163,5 +163,88 @@ JS
"use_shortcut_plan": true
}
]
#
# Counter example with large limit
#
# Table t1 is not the first, have to use temporary+filesort:
set optimizer_join_limit_pref_ratio=0;
explain
select
*
from
t1
join t10 on t1.a=t10.a
join t11 on t1.b=t11.b
order by
t1.col1
limit 5000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10 ALL a NULL NULL NULL 100 Using where; Using temporary; Using filesort
1 SIMPLE t1 ref a,b a 5 test.t10.a 100 Using where
1 SIMPLE t11 ref b b 5 test.t1.b 1
# Same plan as above:
# Table t1 is not the first, have to use temporary+filesort:
set optimizer_join_limit_pref_ratio=10;
explain
select
*
from
t1
join t10 on t1.a=t10.a
join t11 on t1.b=t11.b
order by
t1.col1
limit 5000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10 ALL a NULL NULL NULL 100 Using where; Using temporary; Using filesort
1 SIMPLE t1 ref a,b a 5 test.t10.a 100 Using where
1 SIMPLE t11 ref b b 5 test.t1.b 1
set @trace=(select trace from information_schema.optimizer_trace);
select json_detailed(json_extract(@trace, '$**.limit_shortcut_choice')) as JS;
JS
[
{
"limit_fraction": 0.5,
"test_if_skip_sort_order":
[
{
"reconsidering_access_paths_for_index_ordering":
{
"clause": "ORDER BY",
"fanout": 1,
"read_time": 53.27053125,
"table": "t1",
"rows_estimation": 10000,
"possible_keys":
[
{
"index": "a",
"can_resolve_order": false,
"cause": "not usable index for the query"
},
{
"index": "b",
"can_resolve_order": false,
"cause": "not usable index for the query"
},
{
"index": "col1",
"can_resolve_order": true,
"updated_limit": 5000,
"index_scan_time": 5000,
"usable": false,
"cause": "cost"
}
]
}
}
],
"can_skip_filesort": false,
"full_join_cost": 46064.98442,
"shortcut_join_cost": 24059.12698,
"use_shortcut_plan": false
}
]
set optimizer_trace=@tmp_os;
set optimizer_join_limit_pref_ratio=default;
drop table t1, t10, t11;
mysql-test/main/order_by_limit_join.test
View file @
44b1d7be
...
...
@@ -94,7 +94,33 @@ eval $query;
set
@
trace
=
(
select
trace
from
information_schema
.
optimizer_trace
);
select
json_detailed
(
json_extract
(
@
trace
,
'$**.limit_shortcut_choice'
))
as
JS
;
set
optimizer_trace
=@
tmp_os
;
--
echo
#
--
echo
# Counter example with large limit
--
echo
#
let
$query
=
explain
select
*
from
t1
join
t10
on
t1
.
a
=
t10
.
a
join
t11
on
t1
.
b
=
t11
.
b
order
by
t1
.
col1
limit
5000
;
--
echo
# Table t1 is not the first, have to use temporary+filesort:
set
optimizer_join_limit_pref_ratio
=
0
;
eval
$query
;
--
echo
# Same plan as above:
--
echo
# Table t1 is not the first, have to use temporary+filesort:
set
optimizer_join_limit_pref_ratio
=
10
;
eval
$query
;
set
@
trace
=
(
select
trace
from
information_schema
.
optimizer_trace
);
select
json_detailed
(
json_extract
(
@
trace
,
'$**.limit_shortcut_choice'
))
as
JS
;
set
optimizer_trace
=@
tmp_os
;
set
optimizer_join_limit_pref_ratio
=
default
;
drop
table
t1
,
t10
,
t11
;
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