Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Query Processing & OptimizationEasy
Q1. Query processing involves:
- A.Only creating tables without any query functionality
- B.Only writing queries without any execution or output
- C.Only storing data without any retrieval functionality
- D.Parsing, optimizing, and executing database queries✓ Correct
Explanation
Query processing involves parsing the query, generating execution plans, optimizing, and executing.
Report an error in this question
Query Processing & OptimizationEasy
Q2. A query execution plan describes:
- A.The user who wrote the query and their access privilege details
- B.The table creation date and the schema modification history
- C.The sequence of operations the DBMS will perform to execute a query✓ Correct
- D.The query syntax and grammatical structure in the SQL language
Explanation
An execution plan specifies the strategy and operations the DBMS uses to execute a query.
Report an error in this question
Query Processing & OptimizationEasy
Q3. Query optimization aims to:
- A.Find the most efficient way to execute a query✓ Correct
- B.Make queries longer and more complex to write
- C.Increase the number of disk accesses required
- D.Slow down query processing for all operations
Explanation
Query optimization selects the most efficient execution plan from among alternatives.
Report an error in this question
Query Processing & OptimizationEasy
Q4. The EXPLAIN command in SQL shows:
- A.The database schema layout
- B.The query execution plan✓ Correct
- C.User access permissions
- D.The table data content
Explanation
EXPLAIN displays the execution plan chosen by the query optimizer for a given SQL statement.
Report an error in this question
Query Processing & OptimizationEasy
Q5. A full table scan reads:
- A.Only indexed rows stored
- B.Only the last row stored
- C.Every row in the table✓ Correct
- D.Only the first row found
Explanation
A full table scan reads every row in the table, which is costly for large tables.
Report an error in this question
Query Processing & OptimizationEasy
Q6. Using an index for a query is generally:
- A.Always slower than performing a full table scan
- B.Faster than a full table scan for selective queries✓ Correct
- C.The same speed as a full table scan on all data
- D.Not recommended for any database query at all
Explanation
Index access is faster for selective queries that retrieve a small percentage of rows.
Report an error in this question
Query Processing & OptimizationEasy
Q7. Which join algorithm compares every tuple in one relation with every tuple in another?
- A.Nested Loop Join✓ Correct
- B.Sort-Merge Join
- C.Index Nested Join
- D.Hash Join method
Explanation
Nested loop join compares each tuple in the outer relation with every tuple in the inner relation.
Report an error in this question
Query Processing & OptimizationEasy
Q8. The cost of a query is typically measured in:
- A.Number of SQL statements used
- B.Lines of code in the procedure
- C.Number of disk I/O operations✓ Correct
- D.Number of tables in the schema
Explanation
Query cost is primarily measured by the number of disk I/O (block transfer) operations.
Report an error in this question
Query Processing & OptimizationEasy
Q9. Selectivity of a condition refers to:
- A.The size of the database measured in total bytes
- B.The number of columns selected in the projection
- C.The fraction of tuples that satisfy the condition✓ Correct
- D.The number of tables referenced in the SQL query
Explanation
Selectivity is the ratio of tuples satisfying a condition to the total number of tuples.
Report an error in this question
Query Processing & OptimizationEasy
Q10. A query optimizer can be:
- A.Only cost-based approach
- B.Rule-based or cost-based✓ Correct
- C.Neither rule nor cost based
- D.Only rule-based approach
Explanation
Query optimizers can use rules (heuristics) or cost estimates, or both, to choose execution plans.
Report an error in this question
Query Processing & OptimizationMedium
Q11. Sort-Merge Join works by:
- A.Using a full table scan on both relations without any index use
- B.Sorting both relations on the join attribute and then merging them✓ Correct
- C.Creating a hash table on one relation and probing with the other
- D.Using nested loops to compare every tuple in both the relations
Explanation
Sort-Merge Join sorts both relations on the join attribute, then merges the sorted relations.
Report an error in this question
Query Processing & OptimizationMedium
Q12. Hash Join works by:
- A.Nested iteration comparing every pair of tuples from relations
- B.Sorting both relations on the join attribute and merging results
- C.Using indexes on both tables to find matching join attributes
- D.Building a hash table on one relation and probing with the other✓ Correct
Explanation
Hash join builds a hash table on the smaller relation and probes it with tuples from the larger relation.
Report an error in this question
Query Processing & OptimizationMedium
Q13. An index nested loop join uses:
- A.No index at all on either of the two relations being joined here
- B.An index on the inner relation to find matching tuples efficiently✓ Correct
- C.An index on the outer relation only for scanning its tuple values
- D.A full scan of both relations without using any index structures
Explanation
Index nested loop join uses an index on the inner relation's join attribute for efficient lookups.
Report an error in this question
Query Processing & OptimizationMedium
Q14. Pushing selections down in a query tree:
- A.Increases the size of intermediate results
- B.Removes selections entirely from the plan
- C.Has no effect on the intermediate results
- D.Reduces the size of intermediate results✓ Correct
Explanation
Pushing selections down applies filtering earlier, reducing the number of tuples in intermediate results.
Report an error in this question
Query Processing & OptimizationMedium
Q15. Materialization in query processing means:
- A.Not storing any intermediate results and processing everything in one single pass
- B.Using only indexes to process the query without accessing the base table data
- C.Computing and storing the result of each operation before passing it to the next✓ Correct
- D.Only computing the final result without evaluating any intermediate operations
Explanation
Materialization computes each operation's full result and stores it temporarily before the next operation uses it.
Report an error in this question
Query Processing & OptimizationMedium
Q16. Pipelining in query processing means:
- A.Processing operations one at a time in a strict sequential fashion
- B.Storing all intermediate results on disk before the next operation
- C.Passing tuples from one operation to the next as they are produced✓ Correct
- D.Using only a single CPU core for all database query computations
Explanation
Pipelining sends output tuples of one operation directly to the next operation without materializing.
Report an error in this question
Query Processing & OptimizationMedium
Q17. The catalog statistics used by a cost-based optimizer include:
- A.Only the table name without any other statistical information
- B.Only the primary key definition of each table in the catalog
- C.Number of tuples, number of distinct values, number of blocks✓ Correct
- D.Only column names without cardinality or distribution details
Explanation
Catalog statistics include relation size, distinct values, block count, and index details for cost estimation.
Report an error in this question
Query Processing & OptimizationMedium
Q18. Heuristic optimization rules include:
- A.Perform joins before selections and projections always
- B.Always use Cartesian products first before other joins
- C.Perform selections and projections as early as possible✓ Correct
- D.Avoid using indexes for any data retrieval operations
Explanation
Heuristics like performing selections and projections early reduce intermediate result sizes.
Report an error in this question
Query Processing & OptimizationMedium
Q19. The join ordering problem in query optimization refers to:
- A.Ordering rows within a single table by a specific column
- B.Ordering columns in a table based on their data type size
- C.Determining the most efficient order to join multiple tables✓ Correct
- D.Sorting query results in ascending or descending sequence
Explanation
Join ordering determines which sequence of joins produces the lowest cost for multi-table queries.
Report an error in this question
Query Processing & OptimizationMedium
Q20. Dynamic programming is used in query optimization for:
- A.Creating tables and defining column data types
- B.Parsing SQL queries into abstract syntax trees
- C.Managing locks in the concurrency control layer
- D.Finding the optimal join order for multiple tables✓ Correct
Explanation
Dynamic programming efficiently explores all possible join orders to find the optimal plan.
Report an error in this question
Query Processing & OptimizationHard
Q21. The Selinger optimizer (System R) uses:
- A.Only heuristic rules without any cost estimation being performed
- B.Random plan selection from all possible execution plan choices
- C.Dynamic programming with interesting orders to find optimal plans✓ Correct
- D.No optimization at all with queries running as they are written
Explanation
The System R optimizer uses dynamic programming considering 'interesting orders' (sort orders useful for later operations).
Report an error in this question
Query Processing & OptimizationHard
Q22. An interesting sort order in query optimization is:
- A.Any random sort order applied to tuples without considering the query operations
- B.A sort order used only for displaying the final result to the end user query
- C.A sort order that increases cost by requiring additional sorting in later steps
- D.A sort order produced by one operation that is useful for a subsequent operation✓ Correct
Explanation
An interesting order is a tuple ordering produced by one operation that benefits a later operation (e.g., sort-merge join).
Report an error in this question
Query Processing & OptimizationHard
Q23. The number of possible join orders for n relations is:
- A.Grows exponentially (Catalan number)✓ Correct
- B.Always n squared for n relations
- C.Always n for n given relations total
- D.Exactly n! for n relations total
Explanation
The number of possible join trees grows exponentially; for n relations it is related to Catalan numbers (super-exponential).
Report an error in this question
Query Processing & OptimizationHard
Q24. In cost-based optimization, the estimated cost of a nested loop join R ⋈ S is approximately:
- A.Always 1 block access regardless of the sizes of relations R and S used
- B.b_R plus b_S (sum of blocks from both R and S relations) in simple analysis
- C.n_R plus n_S (sum of tuples from both R and S relations) in simple analysis
- D.n_R times b_S plus b_R (b is blocks, n_R is tuples in R) in simple analysis✓ Correct
Explanation
Simple nested loop join cost is approximately b_R + n_R * b_S block accesses (outer tuples times inner blocks plus outer blocks).
Report an error in this question
Query Processing & OptimizationHard
Q25. Histogram statistics improve query optimization by:
- A.Increasing query complexity by adding more steps to the optimization process
- B.Providing more accurate selectivity estimates for non-uniform data distributions✓ Correct
- C.Removing the need for indexes by providing direct access to all stored records
- D.Making all estimates uniform regardless of the actual data value distribution
Explanation
Histograms capture the distribution of values, allowing better selectivity estimates than assuming uniform distribution.
Report an error in this question
Query Processing & OptimizationHard
Q26. A left-deep join tree is preferred by many optimizers because:
- A.It is the only valid tree shape for all joins
- B.It avoids all disk I/O during the join process
- C.It minimizes the number of tables in joins
- D.It allows pipelining of intermediate results✓ Correct
Explanation
Left-deep trees allow pipelining of join results, avoiding materialization of intermediate results to disk.
Report an error in this question
Query Processing & OptimizationHard
Q27. Adaptive query processing differs from traditional optimization by:
- A.Only optimizing before execution begins and then running without changes
- B.Adjusting the execution plan during query execution based on runtime statistics✓ Correct
- C.Never changing the plan once it has been selected by the query optimizer
- D.Ignoring all statistics and using a fixed plan for every query submitted
Explanation
Adaptive processing monitors runtime conditions and can modify the execution plan during execution.
Report an error in this question
Query Processing & OptimizationHard
Q28. The concept of equivalent query expressions means:
- A.Identical query text that is written exactly the same way in SQL
- B.Different relational algebra expressions that produce the same result✓ Correct
- C.Queries that produce different results from the same input relations
- D.Queries executed on different databases with different table schemas
Explanation
Equivalent expressions produce the same result set, allowing the optimizer to choose the most efficient form.
Report an error in this question
Query Processing & OptimizationHard
Q29. Predicate pushdown in distributed queries:
- A.Ignores remote data sources completely and only queries local tables
- B.Sends all data to a central location first before any filtering occurs
- C.Sends filter conditions to remote data sources to reduce data transfer✓ Correct
- D.Removes all predicates from the query and returns all unfiltered data
Explanation
Predicate pushdown sends WHERE conditions to remote sources so they filter data before sending it, reducing network transfer.
Report an error in this question
Query Processing & OptimizationHard
Q30. Columnar storage benefits analytical queries because:
- A.No indexes are needed for any query on columnar data store
- B.Row storage is used instead of column-oriented data format
- C.All columns are always read regardless of the query needs
- D.Only the needed columns are read from disk, reducing I/O✓ Correct
Explanation
Columnar storage reads only the columns referenced by a query, significantly reducing disk I/O for analytical workloads.
Report an error in this question