Unit 4_Query Processing
Unit 4_Query Processing
■ Overview
■ Measures of Query Cost
■ Selection Operation
■ Sorting
■ Join Operation
■ Other Operations
■ Evaluation of Expressions
■ Negation: (r)
Use linear scan on file
If very few records satisfy , and an index is applicable to
■ For each tuple tr in the outer relation r, use the index to look up
tuples in s that satisfy the join condition with tuple tr.
■ Worst case: buffer has space for only one page of r, and, for each
tuple in r, we perform an index lookup on s.
■ Cost of the join: br + nr c
Where c is the cost of traversing index and fetching all matching s
tuples for one tuple or r
c can be estimated as cost of a single selection on s using the join
condition.
■ If indices are available on join attributes of both r and s,
use the relation with fewer tuples as the outer relation.
n is denoted as nh.
1 . . . i –1 i +1 . . . n
■ Join with a disjunctive condition
r 1 2 ... n s
Either use nested loops/block nested loops, or
Compute as the union of the records in individual joins r i s:
(r 1 s) (r 2 s) . . . (r n s)