Lesson 5 of 5 15 min +250 XP
🧠 Indexing Assessment
Answer all questions to complete the quiz and earn 250 XP.
1
You have a users table with 50 million rows. The query 'SELECT * FROM users WHERE is_active = true' returns 45 million rows. Should you add an index on is_active?
2
Your e-commerce site has this query: 'SELECT * FROM products WHERE category_id = 5 AND price BETWEEN 100 AND 500 ORDER BY rating DESC LIMIT 20'. What's the optimal index?
3
EXPLAIN shows 'Bitmap Heap Scan' after 'Bitmap Index Scan'. What does this indicate?
4
A table has indexes: idx1(A), idx2(A, B), idx3(A, B, C). Which indexes are redundant?
5
Your query uses 'WHERE created_at::date = '2024-03-15''. The index on created_at isn't being used. Why?
6
You need to support both 'WHERE email = ?' and 'WHERE LOWER(email) = ?'. How many indexes do you need?
7
A posts table has 100M rows. You need to show 'SELECT id, title FROM posts WHERE user_id = 123 ORDER BY created_at DESC LIMIT 10'. What index design is optimal?
8
Your analytics query aggregates millions of rows: 'SELECT COUNT(*) FROM events WHERE event_type = 'click''. It's slow despite an index on event_type. What might help?
9
After adding an index, queries are still slow. EXPLAIN shows the index isn't being used. Which is NOT a valid reason?
10
A high-write table (10K inserts/sec) has 5 indexes. Inserts are slow. What should you investigate first?
11
For full-text search on a documents table with a 'content' column, which approach is correct?
12
What's the main difference between GIN and GiST indexes for full-text search?
13
Final question: A query joins 3 tables with WHERE, ORDER BY, and LIMIT. EXPLAIN shows nested loops with 1M iterations. What's the likely issue?
correct