cs4432 - week 6 & 7

55 flashcardsby alicia
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What are the main stages of query processing?
parse convert optimize execute
2
What does the optimizer do?
chooses the best query plan based on cost
3
What is a logical query plan?
relational algebra representation of a query
4
What is a physical query plan?
actual execution strategy with algorithms
5
What determines the best query plan?
estimated cost and statistics
6
What is the goal of query optimization?
minimize intermediate result size
7
What is a key optimization rule?
push selections down
8
What is another optimization rule?
push projections down
9
Why push selections early?
reduces number of tuples processed
10
Why push projections early?
reduces number of attributes processed
11
What are transformation rules?
rules that preserve query equivalence
12
What are the three main evaluation techniques?
indexing iteration partitioning
13
What is indexing used for?
fast retrieval using conditions
14
What is iteration?
scanning tuples sequentially
15
What is partitioning?
divide data into smaller parts using hashing or sorting
16
What is a one-pass algorithm?
process data in one scan
17
What is a two-pass algorithm?
requires two scans of data
18
What is a multi-pass algorithm?
requires multiple scans for large data
19
What limits one-pass algorithms?
data must fit in memory
20
When can one-pass join be used?
when smaller relation fits in memory
21
Memory requirement for one-pass join?
M ≥ B(S) + 1
22
I/O cost of one-pass join?
B(R) + B(S)
23
Condition for duplicate elimination one-pass?
result must fit in memory
24
I/O cost of duplicate elimination one-pass?
B(R)
25
Condition for group by one-pass?
number of groups fits in memory
26
What is a blocking operator?
must process all input before output
27
What is a non-blocking operator?
can output tuples immediately
28
Examples of blocking operators?
group by sorting
29
Examples of non-blocking operators?
selection projection join
30
What happens in pass 1 of external sort?
read M blocks sort write runs
31
What happens in pass 2?
merge sorted runs
32
Constraint for two-pass sort?
B(R) ≤ M²
33
I/O cost of two-pass sort?
3B(R)
34
Steps of sort-merge join?
sort both relations then merge join
35
I/O cost of sort-merge join?
3(B(R)+B(S))
36
What is the main idea of hash-based algorithms?
partition then process each partition
37
What happens in pass 1?
partition data using hash function
38
What happens in pass 2?
process each bucket independently
39
Condition for two-pass hashing?
each bucket fits in memory
40
Constraint formula?
B(R) < M²
41
I/O cost?
3B(R)
42
What is required for hash join?
same hash function on join key
43
What happens after partitioning?
join matching buckets
44
I/O cost of hash join?
3(B(R)+B(S))
45
Constraint for hash join?
smaller relation fits in memory per partition
46
What is B(R)?
number of blocks in relation
47
What is T(R)?
number of tuples
48
What is V(R,A)?
number of distinct values of attribute A
49
Equality selection size?
T(R)/V(R,A)
50
Range selection size?
T(R)/3 if unknown distribution
51
Inequality selection size?
T(R)
52
AND condition estimation?
multiply fractions
53
OR condition estimation?
sum or probabilistic formula
54
Formula for join size?
T(R) × T(S) / max(V(R,Y), V(S,Y))
55
What assumption is used?
uniform distribution
Study all 55 cards for free