3👍
✅
PostgreSQL
supports GIN
and GiST
indexes over intarrays, which allows you to run the queries like this:
SELECT *
FROM mytable
WHERE myarray @> ARRAY[1, 2]
-- returns arrays which contain 1 AND 2
or this:
SELECT *
FROM mytable
WHERE myarray && ARRAY[1, 2]
-- returns arrays which contain 1 OR 2
efficiently.
The first query is somewhat hard to rewrite efficiently using normalized schema.
Source:stackexchange.com