0
0
Supabasecloud~20 mins

Database indexes in Supabase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Database Index Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
What is the main benefit of a database index?

Imagine you have a large table with millions of rows. You want to find rows quickly based on a column value. What does adding an index on that column do?

AIt speeds up data retrieval by allowing the database to find rows faster.
BIt compresses the data to save storage space.
CIt automatically backs up the table data regularly.
DIt encrypts the column data for security.
Attempts:
2 left
💡 Hint

Think about how a book's index helps you find a topic quickly.

service_behavior
intermediate
1:00remaining
What happens when you query a table without an index on the searched column?

You run a query filtering by a column that has no index. What is the expected behavior?

AThe database caches the query results for future use.
BThe database instantly returns results using a hidden index.
CThe query fails with an error about missing indexes.
DThe database scans every row in the table to find matches, which is slower.
Attempts:
2 left
💡 Hint

Without a map or index, how do you find a word in a dictionary?

Configuration
advanced
1:30remaining
Which SQL command creates a unique index on the 'email' column in a Supabase PostgreSQL table named 'users'?

Choose the correct SQL statement to create a unique index on the 'email' column.

ACREATE UNIQUE INDEX idx_users_email ON users(email);
BCREATE INDEX UNIQUE idx_users_email ON users(email);
CCREATE UNIQUE KEY idx_users_email ON users(email);
DCREATE INDEX idx_users_email UNIQUE ON users(email);
Attempts:
2 left
💡 Hint

Remember the correct order of keywords in PostgreSQL for unique indexes.

security
advanced
1:30remaining
What is a potential security risk of indexing sensitive columns like passwords?

Why should you avoid creating indexes on sensitive data columns such as passwords?

AIndexes slow down the database, causing denial of service.
BIndexes store data in plain text, which can expose sensitive information if accessed.
CIndexes prevent data encryption on those columns.
DIndexes automatically share data with third-party services.
Attempts:
2 left
💡 Hint

Think about where index data is stored and who can access it.

Architecture
expert
2:00remaining
In a Supabase project, you want to optimize read performance for a table with frequent writes and reads. Which indexing strategy balances performance best?

Given a table with many inserts and updates, but also many read queries filtering by 'status' and 'created_at', which indexing approach is best?

AAvoid indexes entirely to keep write speed high, accepting slower reads.
BCreate separate indexes on 'status' and 'created_at' columns to maximize read speed at any cost.
CCreate a composite index on (status, created_at) to speed up filtered reads while minimizing write overhead.
DCreate a full-text index on all columns to cover all query types.
Attempts:
2 left
💡 Hint

Think about how composite indexes help with multi-column queries and write costs.