Bird
0
0

Why does the jsonb_path_ops operator class create smaller GIN indexes but is less flexible than jsonb_ops?

hard📝 Conceptual Q10 of 15
PostgreSQL - JSON and JSONB
Why does the jsonb_path_ops operator class create smaller GIN indexes but is less flexible than jsonb_ops?
ABecause jsonb_path_ops indexes only top-level keys and existence, not all key-value pairs.
BBecause jsonb_path_ops compresses data more aggressively, losing some information.
CBecause jsonb_path_ops only supports indexing JSON arrays, not objects.
DBecause jsonb_path_ops requires manual maintenance after inserts.
Step-by-Step Solution
Solution:
  1. Step 1: Understand jsonb_path_ops behavior

    jsonb_path_ops indexes only the existence of top-level keys, making the index smaller.
  2. Step 2: Compare flexibility

    jsonb_ops indexes all keys and values, allowing more flexible queries but creating larger indexes.
  3. Final Answer:

    Because jsonb_path_ops indexes only top-level keys and existence, not all key-value pairs. -> Option A
  4. Quick Check:

    jsonb_path_ops smaller but less flexible due to limited indexing [OK]
Quick Trick: jsonb_path_ops indexes only top-level keys, making smaller indexes [OK]
Common Mistakes:
  • Thinking jsonb_path_ops compresses data
  • Assuming it indexes arrays only
  • Believing it needs manual maintenance

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes