Query Plan Optimization and Cost-Based Estimations

Explore the mechanics of how database query optimizers use data statistics, selectivity, and cost-based models to generate efficient execution plans.

Sample Questions

  1. What is the primary goal of a Cost-Based Optimizer (CBO)?

    • To minimize the estimated resource usage and execution time
    • To always use the most indexes possible
    • To ensure the query plan is generated in under one millisecond
    • To maximize the number of parallel threads
  2. Which metric represents the fraction of rows from a table that satisfy a specific predicate?

    • Cardinality
    • Selectivity
    • Density
    • Clustering Factor
  3. In query optimization, what does 'Cardinality' refer to?

    • The number of columns in a table
    • The number of unique indexes on a table
    • The estimated number of rows returned by an operation
    • The physical size of the data on disk