JSONB, Arrays & FTS

Preview — 3 of 10 questions

What is the key difference between the JSON and JSONB data types in PostgreSQL?

AJSON supports nesting; JSONB only stores flat key-value pairs
BJSONB is limited to 1MB per value; JSON has no size limit
CJSON stores text as-is (preserving whitespace and key order); JSONB stores a parsed binary representation that is faster to query and supports indexing
DJSON supports the -> operator; JSONB uses #> exclusively

Given a JSONB column tags TEXT[], which query finds all rows where the tags array contains both 'postgresql' and 'indexing'?

AWHERE tags = ARRAY['postgresql', 'indexing']
BWHERE tags @> ARRAY['postgresql', 'indexing']
CWHERE tags && ARRAY['postgresql', 'indexing']
DWHERE unnest(tags) IN ('postgresql', 'indexing')

Which query correctly searches for documents containing both 'postgres' and 'performance' using PostgreSQL's full-text search?

AWHERE content LIKE '%postgres%performance%'
BWHERE to_tsvector('english', content) @@ to_tsquery('english', 'postgres & performance')
CWHERE to_tsvector(content) = to_tsquery('postgres performance')
DWHERE fts_rank(content, 'postgres performance') > 0

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.