Query Execution and Optimization
- 35Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What transformation is typically performed on an SQL query before choosing execution algorithms?
The SQL query is translated into a relational algebra expression tree and then rewritten into an equivalent, more execution-friendly form.
Or swipe the card
35 cards
What transformation is typically performed on an SQL query before choosing execution algorithms?
The SQL query is translated into a relational algebra expression tree and then rewritten into an equivalent, more execution-friendly form.
What are heuristic or algebraic query optimizations?
Meaning-preserving rewrites of a relational algebra expression using algebraic rules and optimization heuristics.
What is cost-based query optimization?
Choosing operator algorithms and an overall execution plan based on estimated execution costs.
What does a query execution plan specify?
The methods to use for the operators in the query and how to execute them.
Why can the choice of algorithm for one query operator affect choices elsewhere in the plan?
Operator choices are interdependent: one choice can affect the inputs, costs, or feasible methods of other operators.
Why can query optimizers choose a plan that performs poorly in practice?
They make decisions using estimates, which may not accurately reflect the actual data or execution behavior.
Why do practical query optimizers rely on heuristics?
Finding the optimal combination of operator methods is an intractable optimization problem, so heuristics help search for good plans.
What is the main heuristic for placing selections in a relational algebra tree?
Push selections as close to the leaf relations as possible, before other operations when feasible.
Why does pushing selections toward the leaves reduce query work?
It reduces the number of tuples entering later operators and can shrink intermediate results.
What is the purpose of pushing projections toward the leaves?
To discard attributes as early as possible when they are not needed by later operations.
Which selection predicates can be pushed down to a relation?
Predicates that refer only to attributes of that relation.
How can a conjunction of selection predicates be rewritten?
It can be split into separate selections, and those selections can be applied in either order.
How can a cross product followed by a selection on matching attributes be rewritten?
As a join using the selection condition as the join condition.
Which common relational operations can be reordered because they are commutative?
Selections, joins, unions, and intersections; for example, the order of two selections can be swapped.
How can associativity help when rewriting a query with multiple joins?
It allows joins to be regrouped, such as evaluating a join of three relations using either grouping.
What query result was requested in the lecture's professor example?
The employee ID, name, and phone details of professors who taught a course taken by a specified student in the even semester of 2010.
Which relations are used in the professor-course enrollment example?
Professor (p), teaching (t), and enrollment (e).
What student-specific filter is applied to enrollment in the worked query?
The enrollment record must have roll number CS08B207.
What semester and year conditions are applied in the worked query?
The relevant teaching and enrollment records must be for the even semester of 2010.
How are enrollment records connected to teaching records in the worked query?
By matching their course IDs: e.courseId=t.courseId.
How are professor records connected to teaching records in the worked query?
By matching their employee IDs: p.employeeId=t.employeeId.
Why can the roll-number and semester/year filters be applied before the joins in the worked query?
Each filter refers only to attributes of its own relation, so it can be pushed down to that relation.
After filtering enrollment in the worked query, which attribute must be retained for the join?
The course ID.
Which teaching attributes must be retained for the joins in the worked query?
Course ID and employee ID.
Which professor attributes must be retained for the final result?
Employee ID, name, and phone.
What information is used to estimate the cost of an operator algorithm?
Factors such as operand sizes, file sizes, and whether indexes are available.
How can an optimizer estimate the cost of an operator method?
It can use formulas estimating resource use, such as the number of block accesses, together with relevant data and index information.
What is an intermediate result in a relational algebra execution tree?
The output produced at an internal node of the tree and passed to later operations.
When should an intermediate result be kept in memory or materialized?
Keep it in memory when feasible; materialize it when necessary.
What is pipelining in query execution?
Passing a stream of records from one operation to the next so multiple operations can be applied as records are processed.
How can selection and projection be combined during input processing?
As records are read, apply the selection and retain the required attributes to prepare the result for the next operation.
What is the difference between compiled and ad hoc queries?
Compiled queries are known in advance as part of transactions; ad hoc queries are newly submitted, often by a user or analyst.
Why can compiled queries justify more optimization effort?
They can be optimized offline and may run many times, so the effort spent finding a good plan can pay off across repeated executions.
Why might ad hoc queries use lighter optimization?
They may need quick results, and extensive optimization itself adds performance overhead.
What is a transaction in the context of compiled queries?
A program or unit of work that carries out a logical request, often by issuing several database queries and using their results.

Ask anything
We've read this whole study set, so questions about it get the best answers.