Which of the following best explains how indexes improve query performance in a database?
Think about how searching in a phone book is faster when names are sorted alphabetically.
Indexes create a sorted structure that helps the database quickly locate rows without scanning the entire table, improving query speed.
Which statement correctly distinguishes cost-based query optimization from rule-based optimization?
Consider which method uses data about the database to make decisions.
Cost-based optimization evaluates different query plans using statistics to pick the cheapest, while rule-based uses predefined rules without cost evaluation.
Given a query execution plan showing a full table scan and an index scan, which strategy is generally more efficient and why?
Think about how looking up a word in a dictionary compares to reading every page.
An index scan uses the index to quickly find relevant rows, reducing the number of rows read compared to a full table scan, which reads every row.
Which join strategy is best suited for joining a small table with a large table when the small table fits in memory?
Consider which join uses one table repeatedly to find matches in the other.
Nested loop join is efficient when the smaller table fits in memory, allowing quick lookups for each row in the larger table.
What is the likely effect on query optimization if the database statistics are outdated or missing?
Think about how a GPS might give a bad route if the map is outdated.
Without accurate statistics, the optimizer cannot estimate costs well and may pick slow query plans, but query results remain correct.