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
e0ee80c1
Commit
e0ee80c1
authored
Oct 07, 2019
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the description
parent
a21f5a4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
24 deletions
+18
-24
sql/sql_sort_nest.cc
sql/sql_sort_nest.cc
+18
-24
No files found.
sql/sql_sort_nest.cc
View file @
e0ee80c1
...
@@ -48,26 +48,22 @@ Let's say we have tables
...
@@ -48,26 +48,22 @@ Let's say we have tables
and lets assume the prefix can resolve the ORDER BY clause and we can push
and lets assume the prefix can resolve the ORDER BY clause and we can push
the LIMIT.
the LIMIT.
Mathematically speaking the fanout of the suffix in the join wrt prefix would
So considering the fraction of output we get in a general case with LIMIT is
help us to estimate the fraction of records of the prefix(that are sorted)
that would be read:
+------------------
-------------------------------------+
+
-------------------------------------+
|
|
|
|
f
anout(tk+1....tn)= | cardinality(t1,t2....tn) / cardinality(t1,t2....tk
) |
f
raction = | LIMIT / cardinality(t1,t2....tn
) |
|
|
|
|
+------------------
-------------------------------------+
+
-------------------------------------+
fanout is always >= 1
We assume that the same fraction would be read for the prefix also, so the
records read for the prefix that can resolve the ORDER BY clause is:
So number of records that one would read for the prefix after the LIMIT is
+--------------------------------------+
pushed is
| |
records_read= | fraction * (cardinality(t1,t2....tk) |
+----------------------------+
| |
| |
+--------------------------------------+
records_read= | LIMIT * fanout(tk+1....tn) |
| |
+----------------------------+
+--------------------------------------------------------------+
+--------------------------------------------------------------+
| |
| |
...
@@ -75,11 +71,9 @@ records_read= | LIMIT * fanout(tk+1....tn) |
...
@@ -75,11 +71,9 @@ records_read= | LIMIT * fanout(tk+1....tn) |
| |
| |
+--------------------------------------------------------------+
+--------------------------------------------------------------+
The LIMIT is pushed to all partial join orders enumerated by the join
So the LIMIT is pushed for all partial join orders enumerated by the join
planner that can resolve the ORDER BY clause. This is how we achieve a complete
planner that can resolve the ORDER BY clause.
cost based solution for ORDER BY with LIMIT optimization.
This is how we achieve a complete cost based solution for
ORDER BY with LIMIT optimization.
IMPLEMENTATION DETAILS
IMPLEMENTATION DETAILS
...
@@ -164,7 +158,7 @@ EXECUTION STAGE
...
@@ -164,7 +158,7 @@ EXECUTION STAGE
Let's say we have the best join order as:
Let's say we have the best join order as:
t1, t2, t3, t4 .............tk,tk+1.........................tn
t1, t2, t3, t4 .............tk,tk+1.........................tn
|<---------prefix------------>|<-------suffix--------------->
|<---------prefix------------>|<-------suffix--------------->
|
The prefix are the inner table of the sort nest while the suffix are the
The prefix are the inner table of the sort nest while the suffix are the
tables outside the sort nest.
tables outside the sort nest.
...
@@ -190,7 +184,7 @@ Let's say we have the best join order as:
...
@@ -190,7 +184,7 @@ Let's say we have the best join order as:
execution with the tables in the suffix
execution with the tables in the suffix
<sort nest>, tk+1.........................tn
<sort nest>, tk+1.........................tn
<-------suffix---------------->
|<----------suffix----------->|
The execution stops as soon as we get LIMIT records in the output.
The execution stops as soon as we get LIMIT records in the output.
...
...
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