Final Flashcards
Linear Search (A1) Cost
b_r + t_S
One initial seek
b_r block transfers, where b_r is the number of blocks in a file
Linear Search (A1) Cost, Equality on Key Average Case.
t_s+ (b_r/2). Average case, scan can be terminated as soon as a record is found.
Primary B+-tree Index search, Equality on Key (A2)
(h_i + 1) * t_T
h_i - tree height.
Index traverses tree height and 1 I/O to fetch the record.
Primary B+-tree Index, Equality on Nonkey (A3)
h_i * t_T + b * t_T
Height of the tree and then however many blocks we get
SQL Query Processor Steps
Parser -> Translator -> Optimizer -> Evaluator -> Query Output
Predominant Cost in Evaluation
Disk Access
t_T
Time to transfer one block
t_S
Time for one seek
Generic Cost Algorithm
bt_T + St_S
b_r
Number of blocks containing records from relation r
Secondary Index, Equality on Key (A4)
(h_i+1)*t_t
TF: Index Scans are Search Algorithms
True
b
Blocks with records with the specified search key
Secondary Index, Equality on Nonkey (A4)
(h_i + n) * t_T
Primary Index Comparison (A5)
h_i*t_T + b * t_T
Less than: Start at first tuple and scan until end
Greater than: Use index to find first tuple and scan onwards
Secondary Index Comparison (A6)
(h_i+n) * t_T
Same as A5 but you’re finding pointers to records
Linear file scan might be cheaper
Conjunctive Selection with One Index (A7)
Select algos in A1-7 for lowest cost
Composite Index Matching with Tree Indexes
Involves attributes in prefix of search key. Ex, given a,b,c.
a=1, b=2 is good
a=1, c=3 is bad
Composite Index Matching with Hash Indexes
every term must have a value, order does not matter
Disjunctive Selection (A10)
Can use if all conditions have indices, else use Linear Scan