I can create an index to speed up array operations.
create table test_array as
select id, array[id, id+1, id+2]::text[] as codes
from generate_series(1, 10000) as id;
create index test_array_idx on test_array using GIN (codes);
explain analyze
select * from test_array where codes @> array['123'];
-- Uses "Bitmap Index Scan on test_array_idx"
However, the index doesn't work with integer arrays.
create table test_intarray as
select id, array[id, id+1, id+2] as codes
from generate_series(1, 10000) as id;
create index test_intarray_idx on test_intarray using GIN (codes);
explain analyze
select * from test_intarray where codes @> array[123];
-- Uses "Seq Scan on test_intarray"
Why does that happen?