SQL Database Indexing Quiz

SQL Database
0 Passed
0% acceptance

A 35-question quiz covering indexing fundamentals, lookup efficiency, B-tree behavior, composite indexes, filtering use cases, and index selection strategy.

35 Questions
~70 minutes
1

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?

A
Creating an index on the email column
B
Adding more rows
C
Removing primary keys
D
Using only text data types
2

Question 2

A store frequently filters products by category_id. Which indexing strategy supports faster WHERE category_id = ... lookups?

A
Indexing the category_id column
B
Indexing only the primary key
C
Indexing unrelated columns
D
Avoiding indexes entirely
3

Question 3

A company searches for customers by last_name and first_name together. Which concept supports using both fields for efficient lookups?

A
Composite indexes
B
Foreign keys
C
View definitions
D
Table partitions only
4

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?

A
A functional index on LOWER(name)
B
A CHECK constraint
C
A UNIQUE constraint
D
A partial index with no condition
5

Question 5

An analyst wants to prevent duplicate emails across users. Which index type ensures uniqueness while speeding lookups?

A
UNIQUE index
B
Partial index
C
Bitmap index only
D
Full table replica
6

Question 6

A team has a large table where only active rows are queried frequently. What index design helps skip inactive rows efficiently?

A
Partial index filtering active = true
B
Full index on all rows
C
No index to force table scans
D
Indexing every column
7

Question 7

A developer wonders why indexing a low-selectivity column like 'is_deleted' offers little benefit. What concept explains this?

A
Selectivity influences index usefulness
B
Indexes require composite keys
C
Indexes cannot work on booleans
D
Indexes slow down reading only
8

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?

A
Low selectivity; filtering does not reduce row count much
B
Index corruption
C
Syntax error
D
Primary keys forbid index usage
9

Question 9

A designer notes that ordering results by created_at is slow. What indexing approach supports efficient ORDER BY created_at?

A
Index on created_at
B
Index on unrelated fields
C
Removing created_at column
D
Adding constraints only
10

Question 10

A query filtering by (city, last_name) regularly appears in logs. Which index pattern matches this usage?

A
(city, last_name)' composite index
B
(last_name, city)' composite index only
C
Index on random columns
D
Full table scan preference
11

Question 11

A company tracks products by SKU. Lookups by SKU return a single row. Why is an index especially effective here?

A
High selectivity makes single-row lookups efficient
B
Indexes remove all I/O
C
Indexes require no maintenance
D
Indexes compress data automatically
12

Question 12

A designer wants faster join operations on user_id between orders and customers. Why index user_id in both tables?

A
Indexed join keys allow fast matching of related rows
B
Joins do not use indexes
C
Only primary keys matter for joins
D
Indexes prevent NULL values
13

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?

A
Functions on the column break index usage unless functional indexes exist
B
Indexes never work on decimals
C
Indexes require string types
D
Indexes sort automatically
14

Question 14

A warehouse uses an index to ensure product codes remain unique. Beyond validation, what performance benefit does this provide?

A
Speeds lookups by product code
B
Removes update overhead
C
Reduces memory usage
D
Creates random ordering
15

Question 15

A developer asks whether indexing every column improves overall performance. What core concept disproves this?

A
Indexes add write and maintenance overhead
B
Indexes are weightless
C
Indexes only help reads, not writes
D
Indexes eliminate I/O entirely
16

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?

A
High selectivity of the filter
B
Column naming convention
C
Presence of foreign keys
D
Row formatting style
17

Question 17

A new analyst learns that indexes are stored in tree-like structures. What advantage does this provide for lookups?

A
B-trees reduce lookup paths to logarithmic time
B
Trees eliminate storage costs
C
Trees require no balancing
D
Trees enforce referential integrity
18

Question 18

A query applies ORDER BY last_name. Why does an index on last_name help with sorting?

A
Indexes store values in sorted order
B
Indexes remove the need for ORDER BY
C
Indexes convert strings to integers
D
Indexes force descending order
19

Question 19

A team filters by (region, created_at). Queries rarely filter by region alone. Which composite order is most beneficial?

A
(region, created_at)
B
(created_at, region)
C
(region) only
D
(created_at) only
20

Question 20

A developer designs a partial index for active users. What is the main benefit of partial indexing?

A
Storing only relevant rows allows smaller, faster indexes
B
Partial indexes remove writes
C
Partial indexes apply to all rows
D
Partial indexes enforce foreign keys
21

Question 21

A query planner chooses a table scan despite an index because the filter matches most rows. What concept applies?

A
Low selectivity reduces index usefulness
B
Indexes are disabled automatically
C
Indexes never work on numeric types
D
Primary keys block index use
22

Question 22

A system uses an index on email but adds a filter using CONCAT. Why might the index not be used?

A
Expressions hide the raw column from the index
B
Indexes do not support strings
C
Indexes require UNIQUE
D
Indexes cannot be used for filtering
23

Question 23

A developer wonders why indexes slow down inserts slightly. What structural cost explains this?

A
Indexes must be updated during writes
B
Indexes delete old data
C
Indexes rewrite the table each time
D
Indexes expand I/O arbitrarily
24

Question 24

An application sorts search results by score. A designer wants to reduce the sorting cost. What supports this?

A
Indexing the score column
B
Indexing unrelated text fields
C
Removing ORDER BY
D
Storing scores as text
25

Question 25

A developer asks why indexing a frequently updated column might be avoided. What design trade-off is involved?

A
Frequent updates cause repeated index maintenance
B
Indexes block reads
C
Indexes change NULL behavior
D
Indexes forbid text columns
26

Question 26

A composite index (x, y) is created, but queries filter only by y. Why is the index largely ineffective?

A
Composite indexes follow left-prefix rules
B
Index corruption
C
Indexes need three columns minimum
D
Indexes must be unique to work
27

Question 27

A planning tool reports a bitmap scan combining multiple indexes for complex filtering. Why might multiple indexes be used?

A
Different indexes can filter different conditions before combining results
B
Indexes merge automatically without logic
C
Indexes ignore AND conditions
D
Indexes only work for OR filters
28

Question 28

A designer sees that table scans outperform index scans for tiny tables. Why is this expected?

A
Small tables fit in memory; scanning is cheaper than index traversal
B
Indexes block small-table reads
C
Indexes require joins to function
D
Indexes work only for large tables
29

Question 29

This index is added to speed lookups by email. What type of queries benefit most?

sql
CREATE INDEX idx_users_email ON users(email);
A
Queries filtering WHERE email = ...
B
Queries filtering WHERE id > 0
C
Queries updating unrelated tables
D
COUNT(*) with no filters
30

Question 30

What type of index does this create?

sql
CREATE UNIQUE INDEX idx_users_username ON users(username);
A
A unique index enforcing username uniqueness
B
A partial index
C
A composite index
D
A functional index
31

Question 31

This example creates a composite index. What filter pattern benefits most?

sql
CREATE INDEX idx_orders_customer_date ON orders(customer_id, order_date);
A
WHERE customer_id = ... AND order_date > ...
B
WHERE order_date = ... only
C
WHERE price > ...
D
WHERE order_id < ...
32

Question 32

Why might this functional index be helpful?

sql
CREATE INDEX idx_lower_name ON users(LOWER(name));
A
It supports case-insensitive searches using LOWER(name)
B
It forces name to lowercase permanently
C
It removes whitespace
D
It prevents updates
33

Question 33

What does this partial index optimize?

sql
CREATE INDEX idx_active_users ON users(id) WHERE active = true;
A
Queries filtering WHERE active = true
B
Queries filtering WHERE active = false
C
Sorting by unrelated fields
D
Updates to all users equally
34

Question 34

This structure supports ordering. Which queries benefit?

sql
CREATE INDEX idx_items_created_at ON items(created_at);
A
ORDER BY created_at queries
B
Filtering by unrelated columns
C
COUNT(*) only
D
JOINs on product_id
35

Question 35

This composite index is created, but what usage pattern does it help?

sql
CREATE INDEX idx_logs_level_time ON logs(level, created_at);
A
Filtering WHERE level = ... AND created_at > ...
B
Filtering WHERE created_at = ... only
C
Filtering WHERE message LIKE ...
D
Filtering WHERE id > ...

QUIZZES IN SQL Database