Bird
0
0

You tried to create a GIN index on a JSONB column but got an error: operator class "jsonb_ops" does not exist for access method "gin". What is the likely cause?

medium📝 Debug Q6 of 15
PostgreSQL - JSON and JSONB
You tried to create a GIN index on a JSONB column but got an error: operator class "jsonb_ops" does not exist for access method "gin". What is the likely cause?
AYou forgot to specify the operator class jsonb_ops explicitly.
BThe PostgreSQL version does not support GIN indexes on JSONB.
CYou used the wrong index type; GIN does not support JSONB.
DThe JSONB column contains invalid JSON data.
Step-by-Step Solution
Solution:
  1. Step 1: Understand error meaning

    The error means the GIN index method does not recognize the operator class jsonb_ops, which is standard for JSONB.
  2. Step 2: Identify cause

    This usually happens if PostgreSQL version is older than 9.4, which introduced JSONB and GIN support for it.
  3. Final Answer:

    The PostgreSQL version does not support GIN indexes on JSONB. -> Option B
  4. Quick Check:

    Unsupported PostgreSQL version causes operator class error [OK]
Quick Trick: Check PostgreSQL version supports JSONB GIN indexes [OK]
Common Mistakes:
  • Assuming operator class must be specified manually
  • Thinking GIN does not support JSONB at all
  • Blaming invalid JSON data for index creation error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes