Learning objectives
What you will be able to explain
- Which task is performed by the Parser, but NOT by the Preprocessor?
- Regarding the stages of Query Processing, are the following statements True or False?
- Assign the following tasks to either "Parser" or "Preprocessor":
- In "Pre-Optimization" heuristics, what is the primary goal of "Pushing Down Selections"?
- Identify if the following Relational Algebra equivalences are correct (True) or incorrect (False) for Sets/Bags:
- Which transformation rule allows combining a Selection and a Cartesian Product into a single operator?
Section 01
Which task is performed by the Parser, but NOT by the Preprocessor? to Assign the following tasks to either "Parser" or "Preprocessor":
01
Which task is performed by the Parser, but NOT by the Preprocessor?
The parser is responsible for syntax analysis and grammar-driven parse-tree construction. Semantic tasks such as schema checks, type checks, and view expansion are handled later in preprocessing.
02
Regarding the stages of Query Processing, are the following statements True or False?
A is False because parsing produces a parse tree, not a full logical plan. B is True since preprocessing performs semantic checks. C is True because optimization includes logical rewrites and physical plan selection. D is True because the execution engine runs the physical plan.
03
Assign the following tasks to either "Parser" or "Preprocessor":
Parser tasks are syntax/grammar validation (1 and 4). Preprocessor tasks are semantic and algebraic preparation, such as validating referenced relations and translating to an internal query expression tree (2 and 3).
Section 02
In "Pre-Optimization" heuristics, what is the primary goal of "Pushing Down Selections"? to Which transformation rule allows combining a Selection and a Cartesian Product into a single operator?
01
In "Pre-Optimization" heuristics, what is the primary goal of "Pushing Down Selections"?
Selection push-down applies filters as close to base relations as possible so fewer tuples flow into joins and later operators, reducing intermediate result size and total cost.
02
Identify if the following Relational Algebra equivalences are correct (True) or incorrect (False) for Sets/Bags:
A and D are valid algebraic commutativity/associativity rules. B is also valid because conjunctive selections can be cascaded. C is not always true for bags because duplicate multiplicities make OR-decomposition with union non-equivalent in general.
03
Which transformation rule allows combining a Selection and a Cartesian Product into a single operator?
Join introduction is the rule that recognizes selection-over-cartesian-product as an equi-join pattern and replaces it with an explicit join operator, which is more meaningful and usually cheaper to optimize.
Section 03
Given a relation with tuples and distinct values for attribute . Estimate the number of tuples for the selection assuming a uniform distribution. to A query has a conjunction of two independent predicates: . Given: , , and the selectivity for is . Calculate the estimated result size.
01
Given a relation with tuples and distinct values for attribute . Estimate the number of tuples for the selection assuming a uniform distribution.
Path of Calculation:
1. Formula:
2. Calculation:
Correct Answer: 50
02
Consider relation with and . Estimate the result size for using the "Often better" formula from the slides.
Path of Calculation:
1. Formula:
2. Calculation:
Correct Answer: 14,700
03
A query has a conjunction of two independent predicates: . Given: , , and the selectivity for is . Calculate the estimated result size.
Path of Calculation:
1. Selectivity(A=10) =
2. Selectivity(B<20) =
3. Combined Selectivity =
4. Result Size =
Correct Answer: 100
Section 04
Calculate the result size for a disjunction using Idea 3 (Probability theory). Given: , , and . to Estimate the cardinality of the 3-way join .
01
Calculate the result size for a disjunction using Idea 3 (Probability theory). Given: , , and .
Path of Calculation:
1. Formula:
2.
3.
4.
5. Result =
Correct Answer: 440
02
Estimate the join cardinality for the Natural Join .
Path of Calculation:
1. Formula:
2. Calculation:
Correct Answer: 100,000
Guided checkpoint
| R(X, Y) | S(Y, Z) |
|---|---|
03
Estimate the cardinality of the 3-way join .
Path of Calculation:
1. Step 1: .
2. Step 2: .
3. Use preservation of value sets: .
4. Calculation: .
Correct Answer: 5,000
Guided checkpoint
| R(A, B) | S(B, C) | U(C, D) |
|---|---|---|
Section 05
A relation has 10,000 tuples. Each tuple is 108 bytes. The tuple header is 12 bytes. Blocks are 1,024 bytes with a 24-byte header. Calculate the number of blocks required. to Which of the following are sources for estimation errors in Equi-Width histograms?
01
A relation has 10,000 tuples. Each tuple is 108 bytes. The tuple header is 12 bytes. Blocks are 1,024 bytes with a 24-byte header. Calculate the number of blocks required.
Path of Calculation:
1. Tuple size = bytes.
2. Available space per block = bytes.
3. Tuples per block = tuples.
4. Number of blocks = .
Correct Answer: 1,250
02
Match the Histogram type to its characteristic:
Equi-width histograms define buckets by fixed value-range width (often represented via start and width). Equi-depth histograms define buckets so each bucket contains roughly equal tuple counts, adapting ranges to data skew.
03
Which of the following are sources for estimation errors in Equi-Width histograms?
Equi-width accuracy depends heavily on bucket count and on the uniform-within-bucket assumption. Too few buckets or skew inside a bucket can cause large selectivity errors.
Section 06
Why is "Sampling" often used for collecting statistics in a DBMS? to Which choices are involved in selecting a Physical Query Plan?
01
Why is "Sampling" often used for collecting statistics in a DBMS?
Full-table statistics computation can be expensive on large relations, so DBMSs commonly use sampling to trade a small accuracy loss for much lower collection overhead.
02
What is the "Inclusion Assumption" used in multiple join cardinality estimation?
The inclusion assumption says shared-domain values are assumed to appear across participating relations, which helps approximate multi-join cardinalities without exact cross-relation value correlations.
03
Which choices are involved in selecting a Physical Query Plan?
Physical planning chooses concrete operator implementations, join order/grouping choices among associative operators, and execution/data-flow style (e.g., pipelining vs materialization). Rewriting query semantics (like SELECT to UPDATE) is not part of physical planning.
Section 07
Which search strategy finds a "good" plan quickly and uses its cost as an upper bound to prune further search? to Regarding Join Ordering Heuristics:
01
Which search strategy finds a "good" plan quickly and uses its cost as an upper bound to prune further search?
Branch-and-bound quickly finds a feasible plan, then uses that cost as an upper bound to prune subspaces that cannot beat it, reducing search compared with exhaustive enumeration.
02
What is a significant disadvantage of the Hill-Climbing strategy?
Hill climbing improves a current plan by local moves, but local improvements do not guarantee global optimality. It can therefore stop at a local optimum.
03
Regarding Join Ordering Heuristics:
A is True because greedy methods prioritize immediately cheap join choices. B is False since index scans are often most useful with predicates. C is True because existing sort order can make sort-merge join attractive. D is False because multiple selections are typically pushed together early, not delayed.
Section 08
In Dynamic Programming for Join Ordering, what is the purpose of the "Principle of Optimality"? to What are "Interesting Orders" in Selinger-style optimization?
01
In Dynamic Programming for Join Ordering, what is the purpose of the "Principle of Optimality"?
Dynamic programming relies on optimal substructure: if a full join plan is optimal, its subplans must also be optimal for their subsets. This enables memoization over subsets.
02
In a Dynamic Programming lattice for 4 relations , how many subsets of size 2 (pairs) must be evaluated?
Path of Calculation:
1. Combinations of 4 taken 2 at a time: .
2. Calculation: .
Correct Answer: 6
03
What are "Interesting Orders" in Selinger-style optimization?
Interesting orders are output sort orders worth preserving because downstream operations (merge join, group by, order by) may reuse them and avoid extra sorting.
Section 09
To simplify the search space, which limitations are often applied to Dynamic Programming in optimizers? to According to the quote by T. Neumann, changes to the query optimizer can often improve performance by a factor of:
01
To simplify the search space, which limitations are often applied to Dynamic Programming in optimizers?
To keep DP tractable, optimizers often avoid unnecessary cross products and restrict tree shapes (commonly left-deep). These reduce combinatorial explosion while keeping good plans likely.
02
Assign the following to either "Logical Plan Optimization" or "Physical Plan Optimization":
Logical optimization rewrites algebra equivalently (e.g., push-downs, commutativity). Physical optimization chooses access paths and operator algorithms (scan types, join methods). Hence 1/3 are logical, 2/4 are physical.
03
According to the quote by T. Neumann, changes to the query optimizer can often improve performance by a factor of:
The quoted takeaway is that optimizer quality can have order-of-magnitude impact, commonly around 10x, because plan choices dominate execution cost.
Section 10
Match the execution tree shape to its description: to Which join pair is selected first by the Greedy join-ordering algorithm?
01
Match the execution tree shape to its description:
In left-deep trees, only one side (typically left in this convention) continues as a join subtree while the other is a base relation. Bushy trees allow both children to be join subtrees.
02
Regarding Statistics Collection:
A is False because statistics are usually refreshed periodically, not per update. B is True because even approximate stats guide better plans than none. C is True due to time/update-triggered refresh policies. D is False because stats gathering can be expensive.
03
Which join pair is selected first by the Greedy join-ordering algorithm?
Path of Calculation:
1. Size .
2. Size .
3. Size .
4. Greedy picks the smallest intermediate result.
Correct Answer:
Guided checkpoint
Use Greedy Search on relations with the following statistics:
| Relation | Cardinality |
|---|---|
| 1000 | |
| 10 | |
| 500 |
| Join Pair | Selectivity |
|---|---|
| 0.01 | |
| 0.1 | |
| 0.001 |
Knowledge check
Turn understanding into recall.
The quiz now follows the same concepts in scored form. You can return to this lesson from the quiz whenever a gap appears.