Bird
0
0

Despite having a GIN index on to_tsvector('english', content), a query using to_tsvector('french', content) is slow. What is the most probable reason?

medium📝 Debug Q7 of 15
PostgreSQL - Full-Text Search
Despite having a GIN index on to_tsvector('english', content), a query using to_tsvector('french', content) is slow. What is the most probable reason?
APostgreSQL does not support multiple languages in full-text search.
BThe GIN index does not support full-text search on text columns.
CThe query is missing an explicit <code>WHERE</code> clause.
DThe GIN index was created with a different text search configuration than the query uses.
Step-by-Step Solution
Solution:
  1. Step 1: Understand index configuration

    GIN indexes on full-text search are tied to the text search configuration (language) used in to_tsvector.
  2. Step 2: Check query vs index language

    If the index was created with 'english' but the query uses 'french', the index cannot be used efficiently.
  3. Step 3: Identify cause of slowness

    Because the configurations differ, the index is not utilized, causing slow queries.
  4. Final Answer:

    The GIN index was created with a different text search configuration than the query uses. -> Option D
  5. Quick Check:

    Matching language config between index and query is essential [OK]
Quick Trick: Index and query must use same language config [OK]
Common Mistakes:
  • Assuming GIN indexes work regardless of language config
  • Believing GIN indexes support all languages automatically
  • Ignoring the need to recreate index for different languages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes