Bird
0
0

A GiST index on a box column is not being used by the query:

medium📝 Debug Q7 of 15
PostgreSQL - Indexing Strategies
A GiST index on a box column is not being used by the query:

SELECT * FROM shapes WHERE box <@ '(0,0),(5,5)'::box;

What is a possible reason?
AThe query syntax is incorrect
BThe index was created on a different column
CThe <code><@</code> operator is not supported by the GiST index for boxes
DThe box data type is incompatible with GiST
Step-by-Step Solution
Solution:
  1. Step 1: Verify index column

    A possible reason the GiST index is not used is if it was created on a different column than "box". Column names must match exactly.
  2. Step 2: Rule out others

    Query syntax is valid. <@ (contained by) is supported by GiST on box. box type is compatible with GiST.
  3. Final Answer:

    The index was created on a different column -> Option B
  4. Quick Check:

    Index column name mismatch prevents usage [OK]
Quick Trick: Ensure index column matches WHERE clause column [OK]
Common Mistakes:
  • Overlooking column name mismatch
  • Mistakenly thinking <@ unsupported
  • Assuming invalid syntax or incompatible type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes