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
a14b5d24
Commit
a14b5d24
authored
Aug 16, 2009
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MWL#17: Table elimination
- More comments
parent
69d4559e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
13 deletions
+49
-13
sql/opt_table_elimination.cc
sql/opt_table_elimination.cc
+49
-13
No files found.
sql/opt_table_elimination.cc
View file @
a14b5d24
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
Table elimination is redone on every PS re-execution.
Table elimination is redone on every PS re-execution.
IMPLEMENTATION
TABLE ELIMINATION ALGORITHM
As said above, we can remove inner side of an outer join if it is
As said above, we can remove inner side of an outer join if it is
...
@@ -67,23 +67,59 @@
...
@@ -67,23 +67,59 @@
We check #1 by doing a recursive descent down the join->join_list while
We check #1 by doing a recursive descent down the join->join_list while
maintaining a union of used_tables() attribute of all expressions we've seen
maintaining a union of used_tables() attribute of all expressions we've seen
"elsewhere". When we encounter an outer join, we check if the bitmap of
"elsewhere". When we encounter an outer join, we check if the bitmap of
tables on its inner side has
intersection with tables that are used
tables on its inner side has
an intersection with tables that are used
elsewhere. No intersection means that inner side of the outer join could
elsewhere. No intersection means that inner side of the outer join could
potentially be eliminated.
potentially be eliminated.
#2 is checked using a concept of values and modules that indicate
In order to check #2, one needs to prove that inner side of an outer join
dependencies between them.
is functionally dependent on the outside. We prove dependency by proving
functional dependency of intermediate objects:
We start with
- Inner side of outer join is functionally dependent when each of its tables
of certain values that functional dependencies between
are functionally dependent. (We assume a table is functionally dependent
them. There are two kinds of values:
when its dependencies allow to uniquely identify one table record, or no
*/
records).
/*
- Table is functionally dependent when it has got a unique key whose columns
A value
are functionally dependent.
functional dependencies between two kinds of entities:
- A column is functionally dependent when we could locate an AND-part of a
certain ON clause in form
tblX.columnY= expr
where expr is functionally-depdendent.
Apparently the above rules can be applied recursively. Also, certain entities
depend on multiple other entities. We model this by a bipartite graph which
has two kinds of nodes:
Value nodes:
- Table column values (each is a value of tblX.columnY)
- Table nodes (each node represents a table inside an eliminable join nest).
each value is either bound (i.e. functionally dependent) or not.
Module nodes:
- Nodes representing tblX.colY=expr equalities. Equality node has
= incoming edges from columns used in expr
= outgoing edge to tblX.colY column.
- Nodes representing unique keys. Unique key has
= incoming edges from key component value nodes
= outgoing edge to key's table node
- Inner side of outer join node. Outer join node has
= incoming edges from table value nodes
= No outgoing edges. Once we reach it, we know we can eliminate the
outer join.
A module may depend on multiple values, and hence its primary attribute is
the number of its depedencies that are not bound.
The algorithm starts with equality nodes that don't have any incoming edges
(their expressions are either constant or depend only on tables that are
outside of any outer joins) and proceeds to traverse dependency->dependant
edges until we've other traversed everything (TODO rephrase elaborate), or
we've reached the point where all outer join modules have zero unsatisfied
dependencies.
*/
*/
class
Value_dep
;
class
Value_dep
;
...
...
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