Bird
0
0

You created a GIN index on a JSONB column but your queries are still slow. What is the most likely cause?

medium📝 Debug Q14 of 15
PostgreSQL - JSON and JSONB
You created a GIN index on a JSONB column but your queries are still slow. What is the most likely cause?
AThe GIN index does not support JSONB data types
BThe index was created without specifying the JSONB column
CThe queries are not using the <code>@></code> operator
DThe table has no rows
Step-by-Step Solution
Solution:
  1. Step 1: Understand when GIN index helps

    GIN indexes on JSONB columns speed up queries that use operators like @> which check for containment.
  2. Step 2: Identify why queries remain slow

    If queries do not use @> or other supported operators, the index won't be used, causing slow performance.
  3. Final Answer:

    The queries are not using the @> operator -> Option C
  4. Quick Check:

    GIN index helps only with supported operators [OK]
Quick Trick: Use @> operator to leverage GIN index speedup [OK]
Common Mistakes:
  • Assuming GIN indexes speed up all JSONB queries
  • Not verifying query operator usage
  • Thinking GIN index doesn't support JSONB

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes