Bird
0
0

Given the table documents with a column content_tsv of type tsvector, what will this query return?

medium📝 query result Q13 of 15
PostgreSQL - Full-Text Search
Given the table documents with a column content_tsv of type tsvector, what will this query return?
SELECT id FROM documents WHERE content_tsv @@ to_tsquery('cat & dog');
ARows where content contains both 'cat' and 'dog'
BRows where content contains either 'cat' or 'dog'
CRows where content contains the exact phrase 'cat dog'
DRows where content contains 'cat' but not 'dog'
Step-by-Step Solution
Solution:
  1. Step 1: Understand to_tsquery('cat & dog')

    The & operator means AND, so it searches for both words.
  2. Step 2: Apply @@ operator

    The query returns rows where content_tsv matches both 'cat' and 'dog'.
  3. Final Answer:

    Rows where content contains both 'cat' and 'dog' -> Option A
  4. Quick Check:

    AND operator & means both words [OK]
Quick Trick: Use & in tsquery for AND search [OK]
Common Mistakes:
  • Thinking & means OR
  • Assuming phrase match instead of AND
  • Confusing tsquery syntax operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes