Bird
0
0

You have a table with a jsonb column but your query is slow when filtering by keys. What is the most likely cause?

medium📝 Debug Q14 of 15
PostgreSQL - JSON and JSONB
You have a table with a jsonb column but your query is slow when filtering by keys. What is the most likely cause?
ANo GIN or BTREE index on the <code>jsonb</code> column
BUsing <code>json</code> type instead of <code>jsonb</code>
CThe JSON data is stored as plain text
DThe query uses <code>LIKE</code> operator on the <code>jsonb</code> column
Step-by-Step Solution
Solution:
  1. Step 1: Understand indexing for jsonb

    jsonb supports GIN or BTREE indexes to speed up key/value lookups.
  2. Step 2: Identify cause of slow queries

    If no index exists on the jsonb column, queries filtering by keys must scan all rows, causing slowness.
  3. Final Answer:

    No GIN or BTREE index on the jsonb column -> Option A
  4. Quick Check:

    Missing index on jsonb = slow queries [OK]
Quick Trick: Add GIN index on jsonb for fast key lookups [OK]
Common Mistakes:
  • Confusing json and jsonb types
  • Using LIKE on jsonb instead of jsonb operators
  • Ignoring indexing for jsonb columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes