Bird
0
0

What will be the result of this query if the GIN index exists?

medium📝 query result Q5 of 15
PostgreSQL - Full-Text Search
What will be the result of this query if the GIN index exists?
EXPLAIN SELECT * FROM docs WHERE to_tsvector('english', text) @@ to_tsquery('english', 'search');
AQuery plan shows sequential scan only
BQuery plan shows use of GIN index scan
CQuery returns an error about missing index
DQuery plan shows hash index scan
Step-by-Step Solution
Solution:
  1. Step 1: Understand EXPLAIN output with GIN index

    When a GIN index exists, EXPLAIN shows an Index Scan using GIN.
  2. Step 2: Recognize scan types

    Sequential scan means no index used; hash index is not used for full-text search.
  3. Final Answer:

    Query plan shows use of GIN index scan -> Option B
  4. Quick Check:

    EXPLAIN with GIN index = Index Scan [OK]
Quick Trick: EXPLAIN shows GIN index scan if index is used [OK]
Common Mistakes:
  • Expecting hash index for full-text search
  • Assuming sequential scan always happens
  • Thinking query errors without index

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes