Recall & Review
beginner
What is a composite index in a database?
A composite index is an index that includes more than one column from a table. It helps speed up queries that filter or sort by multiple columns together.
Click to reveal answer
intermediate
Why does the order of columns matter in a composite index?
The order matters because the database uses the index starting from the first column. Queries filtering on the first column(s) can use the index efficiently, but if the first column is missing in the query, the index might not be used.
Click to reveal answer
intermediate
Given a composite index on (A, B), which query can use the index efficiently?
A query filtering on column A alone or on both A and B can use the index efficiently. But a query filtering only on B cannot use the index effectively.
Click to reveal answer
beginner
How does a composite index improve query performance?
It allows the database to quickly find rows matching multiple column conditions without scanning the whole table, reducing search time.
Click to reveal answer
intermediate
What happens if you reverse the column order in a composite index?
Reversing the order changes which queries can use the index efficiently. For example, an index on (B, A) helps queries filtering on B first, but not those filtering only on A.
Click to reveal answer
What is a composite index?
✗ Incorrect
A composite index includes more than one column to speed up queries involving those columns.
If you have a composite index on (A, B), which query can use it efficiently?
✗ Incorrect
The index can be used efficiently when filtering on the first column A or both A and B, but not on B alone.
Why does column order matter in a composite index?
✗ Incorrect
The database uses the index starting from the first column, so queries must filter on that column to use the index.
What is the main benefit of using a composite index?
✗ Incorrect
Composite indexes speed up queries that filter or sort by multiple columns.
If you have an index on (B, A), which query is less likely to use it efficiently?
✗ Incorrect
Queries filtering only on A cannot use an index starting with B efficiently.
Explain what a composite index is and why the order of columns matters.
Think about how the database searches using the index.
You got /4 concepts.
Describe how a composite index can improve query performance and give an example of when it might not be used.
Consider which columns the query filters on compared to the index order.
You got /4 concepts.