GIN, GiST & BRIN

Preview — 3 of 10 questions

What condition must be met for PostgreSQL to perform an index-only scan?

AThe table must have fewer than 10,000 rows
BThe index must be a UNIQUE index
CThe query must use LIMIT 1
DAll columns referenced in the query must be present in the index (as key or INCLUDE columns), and the visibility map must show the page as all-visible

Which index type should you use to efficiently query WHERE 'postgresql' = ANY(tags) where tags is a text[] column?

javascript
CREATE INDEX idx_products_tags ON products USING GIN (tags);

-- These queries use the GIN index:
SELECT * FROM products WHERE tags @> ARRAY['postgresql'];
SELECT * FROM products WHERE 'nosql' = ANY(tags);
AGIN (Generalized Inverted Index) on tags
BHash index on tags
CB-tree index on tags
DBRIN index on tags

Which operator benefits from a GIN index on a jsonb column?

A->> (extract field as text)
B::text LIKE '%value%'
C@> (JSON containment)
Djsonb_array_length()

Sign up free to play

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