is the process of selecting the most efficient query-evaluation plan from among the many strategies usually possible for processing a given query, especially if the query is complex.
Query Optimization
to find an expression that is equivalent to the given expression, but more efficient to execute.
relational-algebra level
defines exactly what algorithm should be used for each operation and how the execution of the operations should be coordinated.
Evaluation plan
provide a way to view the evaluation plan chosen to execute
a given query.
databases
displays the execution plan chosen for the specified query <query>.</query>
explain <query></query>
the command stores the resultant plan in a table called plan table, instead of displaying it.
explain plan for
displays the stored plan
select * from table
DB2 follows a simil arapproach to Oracle, but requires this program to be executed to display the stored plan.
db2exfmt
to be executed before
submitting the query; then, when a query is submitted, instead of executing the query, the evaluation plan is displayed.
set showplan_text
are said to be equivalent if on every legal database the
two expressions generate the same multiset of tuples.
multiset relational algebra
states that two relational-algebra expressions are equivalent and can replace each other since they always produce the same result on any valid database.
equivalence rule
Query optimizers use these rules to transform expressions into more efficient but logically equivalent forms.
equivalence rule
operations are associative
Natural-join
A set of equivalence rules is this if no rule can be derived from the others.
minimal
can be deconstructed into a sequence of individual selections.
Conjunctive selection
is important for reducing the size of temporary results
Join Ordering
the number of tuples in the relation r
nr
the number of blocks containing tuples of relation r.
br
the size of a tuple of relation r in bytes.
lr
the blocking factor of relation r—that is, the number of tuples of relation r that
f t into one block.
fr
the number of distinct values that appear in the relation r for attribute A.
V(A,r)
the values for the attribute are divided into a number of ranges, and with each range the histogram associates the number of tuples whose attribute value lies in that range.
histogram
divides the range of values into equal-sized ranges
equi-width histogram
adjusts the boundaries of the ranges such that each range has the same number of values.
equi-depth histogram