1. Home
  2. Explore
  3. Computer Science
  4. Query Execution and Optimization

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Query Execution and Optimization

  • 54Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Query Plans
Before execution, an SQL query is converted into a relational algebra
.

54 questions

  1. 1
    Before execution, an SQL query is converted into a relational algebra
    _____
    .
    Hint

    Think of the tree-shaped representation of the query's operations.

    Answer

    expression tree

  2. 2
    The operators in a relational algebra expression tree are executed using appropriate
    _____
    .
    Hint

    These are alternative procedures for carrying out operations such as joins.

    Answer

    algorithms

  3. 3
    Before executing a query, the initial relational algebra expression is rewritten in a way that preserves its
    _____
    .
    Hint

    The transformed expression must return the same result as the original.

    Answer

    meaning

  4. 4
    Meaning-preserving query rewrites can use heuristics and
    _____
    transformations.
    Hint

    These transformations use the laws of relational algebra.

    Answer

    algebraic

  5. 5
    Rewriting an expression into a form more suitable for execution is called heuristic or algebraic
    _____
    .
    Hint

    This process improves the expression before selecting specific execution methods.

    Answer

    optimization

  6. 6
    After the final relational algebra tree is generated, the optimizer estimates operator costs in a step called
    _____
    query optimization.
    Hint

    This optimization compares estimated costs of alternative methods.

    Answer

    cost based

  7. 7
    An execution plan specifies which
    _____
    will be used for each operator in the query.
    Hint

    The plan fixes how each operation will be carried out.

    Answer

    method

  8. 8
    A central heuristic is to push selection and projection operations as close as possible to the
    _____
    of the relational algebra tree.
    Hint

    These are the bottom nodes, where base relations appear.

    Answer

    leaves

  9. 9
    In a relational algebra tree, the leaf nodes normally contain the database's base
    _____
    .
    Hint

    These are the underlying tables used by the query.

    Answer

    relations

  10. 10
    Pushing selections toward the leaves reduces the number of tuples entering later operations, making intermediate results
    _____
    .
    Hint

    Filtering early means fewer records have to be processed downstream.

    Answer

    smaller

  11. 11
    Pushing projections toward the leaves reduces the number of
    _____
    carried in intermediate results.
    Hint

    Projection keeps selected attributes rather than all attributes.

    Answer

    fields

  12. 12
    The results produced at internal nodes of a relational algebra tree are called
    _____
    results.
    Hint

    They are produced before the final query result.

    Answer

    intermediate

  13. 13
    If a conjunction contains multiple selection conditions, the conditions can be applied in any
    _____
    .
    Hint

    The selection operations can be rearranged without changing the result.

    Answer

    order

  14. 14
    When two selections are applied, their order can be changed because selection is
    _____
    .
    Hint

    This algebraic property allows the order of the two operations to be swapped.

    Answer

    commutative

  15. 15
    The join expressions AAA join BBB and BBB join AAA illustrate the commutative property of
    _____
    .
    Hint

    The operation combines tuples from two relations.

    Answer

    join

  16. 16
    Associativity allows a sequence of joins such as AAA join BBB join CCC to be
    _____
    in different groupings.
    Hint

    The relations can be combined with different parentheses while preserving the result.

    Answer

    written

  17. 17
    A selection condition involving only one relation can be pushed down to that relation's
    _____
    in the tree.
    Hint

    Apply the condition close to the input it concerns.

    Answer

    operand

  18. 18
    A cross product followed by a selection on the combined relations can be replaced by a
    _____
    .
    Hint

    This combined relational operation uses the selection condition to match tuples.

    Answer

    join

  19. 19
    In the example query, a predicate involving all three relations cannot be pushed down to just one relation because it depends on
    _____
    relations.
    Hint

    The predicate needs information from professor, teaching, and enrollment.

    Answer

    all three

  20. 20
    A relational algebra operator such as a join may have several applicable
    _____
    for its evaluation.
    Hint

    For example, different join procedures may be available.

    Answer

    algorithms

  21. 21
    A cost function estimates the work required to use a particular operator
    _____
    .
    Hint

    It evaluates the expected expense of one way of performing the operation.

    Answer

    method

  22. 22
    The number of block accesses performed by an algorithm can be used to estimate its
    _____
    .
    Hint

    This measures the resources the method is expected to consume.

    Answer

    cost

  23. 23
    Cost estimates can depend on the sizes of both operands and on the availability of
    _____
    .
    Hint

    These data structures can affect how efficiently records are found.

    Answer

    indexes

  24. 24
    Choosing a method for one operator can affect choices elsewhere because operators in the tree are
    _____
    .
    Hint

    A decision in one part of the plan may constrain or change another decision.

    Answer

    interdependent

  25. 25
    Because operator choices affect one another, the optimizer must consider them in a
    _____
    manner.
    Hint

    The choices should be evaluated as parts of one overall problem.

    Answer

    combined

  26. 26
    Finding the best combination of operator methods is described as an
    _____
    problem.
    Hint

    The problem is difficult enough that practical optimizers rely on shortcuts.

    Answer

    intractable

  27. 27
    Since exact optimization is difficult, query optimizers rely heavily on
    _____
    .
    Hint

    These are practical rules that guide the search for a good plan.

    Answer

    heuristics

  28. 28
    The overall estimated plan cost is based on the estimated costs of the chosen methods for the plan's
    _____
    .
    Hint

    Each relational algebra operation contributes to the plan's total estimate.

    Answer

    operators

  29. 29
    A cost-based optimizer selects the plan with the best estimated
    _____
    .
    Hint

    The optimizer compares the predicted expense of candidate plans.

    Answer

    cost

  30. 30
    Cost-based optimizers can make poor choices because their decisions rely on
    _____
    rather than exact knowledge of future execution.
    Hint

    Predicted costs may not match what happens with the actual data.

    Answer

    estimates

  31. 31
    In the example, the query seeks professor names and phone details for professors who taught a course taken by a student with a specified
    _____
    .
    Hint

    This value identifies the student whose enrollment is checked.

    Answer

    roll number

  32. 32
    The example query uses the Professor, Teaching, and
    _____
    relations.
    Hint

    This relation records which students are registered for courses.

    Answer

    Enrollment

  33. 33
    The professor's teaching assignment is matched to a student's enrollment using the shared
    _____
    .
    Hint

    This attribute identifies the course in both relations.

    Answer

    courseId

  34. 34
    The professor relation is connected to the teaching relation by matching their
    _____
    .
    Hint

    This attribute identifies the professor who teaches the course.

    Answer

    employeeId

  35. 35
    The example restricts both enrollment and teaching records to the
    _____
    semester.
    Hint

    The query specifies one of the two semester categories.

    Answer

    even

  36. 36
    The example also restricts the relevant enrollment and teaching records to the year
    _____
    .
    Hint

    This is the year specified in the query conditions.

    Answer

    2010

  37. 37
    The initial relational algebra expression represents the three relations with a cross product, applies a selection using the full condition, and then uses a
    _____
    for the requested attributes.
    Hint

    This operation keeps only selected attributes in the output.

    Answer

    projection

  38. 38
    Because the example's where conditions are a conjunction, they can be broken into separate
    _____
    .
    Hint

    Each individual condition can be considered and placed separately.

    Answer

    predicates

  39. 39
    The predicate on the student's roll number applies directly to the
    _____
    relation.
    Hint

    The student's course registration records contain the roll number.

    Answer

    Enrollment

  40. 40
    The example separates the employee identifier match from the course identifier match so each join condition can be placed with the appropriate
    _____
    .
    Hint

    Each condition concerns a particular pair of inputs.

    Answer

    relations

  41. 41
    After filtering Enrollment in the example, only courseId needs to be projected from it because that is the attribute required by the later
    _____
    .
    Hint

    The remaining operation matches enrollment courses with courses being taught.

    Answer

    join

  42. 42
    After filtering Teaching, the example retains courseId and employeeId because both are needed by later
    _____
    .
    Hint

    One attribute links courses, while the other links the professor.

    Answer

    joins

  43. 43
    From Professor, the example retains employeeId, name, and phone because they are needed for joining or the final
    _____
    .
    Hint

    Some attributes identify the professor, while others are requested by the query.

    Answer

    output

  44. 44
    A projection should avoid carrying an attribute upward if it will not be needed by any later operation or the final
    _____
    .
    Hint

    Keep only attributes that contribute to something the query must produce.

    Answer

    result

  45. 45
    Applying selection and projection while records are being read combines work instead of writing a filtered relation and processing it later; this uses
    _____
    .
    Hint

    The operations are applied as a stream of records moves through the plan.

    Answer

    pipelining

  46. 46
    An intermediate relation that fits in memory is generally better kept
    _____
    rather than materialized.
    Hint

    Avoid writing temporary results to storage when they can be handled in available working space.

    Answer

    in memory

  47. 47
    Materializing an intermediate table may be necessary when it cannot be handled in
    _____
    .
    Hint

    This is the working space in which a small intermediate result can be kept.

    Answer

    memory

  48. 48
    Compiled queries are known in advance because they are part of database
    _____
    .
    Hint

    These are organized pieces of work that carry out logical requests.

    Answer

    transactions

  49. 49
    Because compiled queries are known beforehand, their plans can be optimized and fixed
    _____
    .
    Hint

    The optimization can occur before the query is run.

    Answer

    offline

  50. 50
    Compiled queries can justify spending more time on optimization because they may be executed
    _____
    of times.
    Hint

    The plan may be reused repeatedly rather than run only once.

    Answer

    hundreds

  51. 51
    An ad hoc query is a new query supplied by a user, such as an analyst working at a
    _____
    .
    Hint

    The user enters the query directly rather than relying on a precompiled one.

    Answer

    terminal

  52. 52
    Ad hoc queries often need quick optimization because the user is expecting
    _____
    results.
    Hint

    The query is new, and the user does not want to wait for extensive plan search.

    Answer

    fast

  53. 53
    Extensive optimization has a performance
    _____
    of its own.
    Hint

    Optimization consumes time and resources before query execution.

    Answer

    penalty

  54. 54
    To limit optimization overhead for ad hoc queries, a system may use
    _____
    versions of optimization.
    Hint

    These approaches perform less optimization work than a thorough offline search.

    Answer

    lighter

1 of 54
Question 1 of 54

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent