0
0
SQLquery~5 mins

Composite index and column order in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AA type of table
BAn index on a single column
CAn index on multiple columns
DA database user
If you have a composite index on (A, B), which query can use it efficiently?
AWHERE C = 5
BWHERE B = 5
CWHERE B = 5 AND A = 10
DWHERE A = 5
Why does column order matter in a composite index?
ABecause the database uses the index starting from the first column
BBecause the last column is always ignored
CBecause columns are sorted alphabetically
DBecause indexes only work on one column
What is the main benefit of using a composite index?
AFaster queries on multiple columns
BMore storage space
CSlower inserts
DLess data in the table
If you have an index on (B, A), which query is less likely to use it efficiently?
AWHERE B = 10
BWHERE A = 10
CWHERE B = 10 AND A = 20
DWHERE B > 5
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.