SQL Database Indexing Quiz
A 35-question quiz covering indexing fundamentals, lookup efficiency, B-tree behavior, composite indexes, filtering use cases, and index selection strategy.
Question 1
A team notices queries scanning the entire customer table to find matches by email. They want faster lookups for this field. What general concept helps speed up such searches?
Question 2
A store frequently filters products by category_id. Which indexing strategy supports faster WHERE category_id = ... lookups?
Question 3
A company searches for customers by last_name and first_name together. Which concept supports using both fields for efficient lookups?
Question 4
A query planner avoids using an index even though one exists. The filter compares an unindexed expression like LOWER(name). What index type could be used?
Question 5
An analyst wants to prevent duplicate emails across users. Which index type ensures uniqueness while speeding lookups?
Question 6
A team has a large table where only active rows are queried frequently. What index design helps skip inactive rows efficiently?
Question 7
A developer wonders why indexing a low-selectivity column like 'is_deleted' offers little benefit. What concept explains this?
Question 8
A search filters by state, but the planner prefers scanning the table. Only a few states exist. What explains the index not being used?
Question 9
A designer notes that ordering results by created_at is slow. What indexing approach supports efficient ORDER BY created_at?
Question 10
A query filtering by (city, last_name) regularly appears in logs. Which index pattern matches this usage?
Question 11
A company tracks products by SKU. Lookups by SKU return a single row. Why is an index especially effective here?
Question 12
A designer wants faster join operations on user_id between orders and customers. Why index user_id in both tables?
Question 13
A query applies a filter on price but wraps it in a function like ROUND(price). Why does the planner skip the index?
Question 14
A warehouse uses an index to ensure product codes remain unique. Beyond validation, what performance benefit does this provide?
Question 15
A developer asks whether indexing every column improves overall performance. What core concept disproves this?
Question 16
A planner chooses an index scan instead of a table scan because only a small percentage of rows match a condition. What factor influenced this choice?
Question 17
A new analyst learns that indexes are stored in tree-like structures. What advantage does this provide for lookups?
Question 18
A query applies ORDER BY last_name. Why does an index on last_name help with sorting?
Question 19
A team filters by (region, created_at). Queries rarely filter by region alone. Which composite order is most beneficial?
Question 20
A developer designs a partial index for active users. What is the main benefit of partial indexing?
Question 21
A query planner chooses a table scan despite an index because the filter matches most rows. What concept applies?
Question 22
A system uses an index on email but adds a filter using CONCAT. Why might the index not be used?
Question 23
A developer wonders why indexes slow down inserts slightly. What structural cost explains this?
Question 24
An application sorts search results by score. A designer wants to reduce the sorting cost. What supports this?
Question 25
A developer asks why indexing a frequently updated column might be avoided. What design trade-off is involved?
Question 26
A composite index (x, y) is created, but queries filter only by y. Why is the index largely ineffective?
Question 27
A planning tool reports a bitmap scan combining multiple indexes for complex filtering. Why might multiple indexes be used?
Question 28
A designer sees that table scans outperform index scans for tiny tables. Why is this expected?
Question 29
This index is added to speed lookups by email. What type of queries benefit most?
CREATE INDEX idx_users_email ON users(email);Question 30
What type of index does this create?
CREATE UNIQUE INDEX idx_users_username ON users(username);Question 31
This example creates a composite index. What filter pattern benefits most?
CREATE INDEX idx_orders_customer_date ON orders(customer_id, order_date);Question 32
Why might this functional index be helpful?
CREATE INDEX idx_lower_name ON users(LOWER(name));Question 33
What does this partial index optimize?
CREATE INDEX idx_active_users ON users(id) WHERE active = true;Question 34
This structure supports ordering. Which queries benefit?
CREATE INDEX idx_items_created_at ON items(created_at);Question 35
This composite index is created, but what usage pattern does it help?
CREATE INDEX idx_logs_level_time ON logs(level, created_at);