Bird
0
0

You created an index on email column but queries filtering by email are still slow. What is a likely cause?

medium📝 Debug Q6 of 15
PostgreSQL - Indexing Strategies
You created an index on email column but queries filtering by email are still slow. What is a likely cause?
AThe index is not used because the query applies a function on email (e.g., LOWER(email))
BThe index was created on the wrong table
CPostgreSQL does not support indexes on text columns
DThe email column contains only unique values
Step-by-Step Solution
Solution:
  1. Step 1: Understand index usage with functions

    Indexes on columns are not used if queries apply functions unless functional indexes exist.
  2. Step 2: Analyze the query behavior

    If the query uses LOWER(email), the normal index on email is ignored, causing slow scans.
  3. Final Answer:

    The index is not used because the query applies a function on email (e.g., LOWER(email)) -> Option A
  4. Quick Check:

    Functions on columns require functional indexes [OK]
Quick Trick: Use functional indexes when querying with functions on columns [OK]
Common Mistakes:
  • Assuming indexes don't work on text
  • Ignoring function usage in queries
  • Thinking unique values slow queries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes