As recommended by this comment, I built an intarray GIN index. I even set local enable_seqscan = 'off';
. Still, when I EXPLAIN
my query, it is doing the sequential scan. For demonstration, I created a dummy table called deletethis
.
devapp=>
devapp=> \d deletethis;
Table "public.deletethis"
Column | Type | Collation | Nullable | Default
--------+-----------+-----------+----------+---------
col1 | integer[] | | |
Indexes:
"deletethis_idx" gin (col1 gin__int_ops)
devapp=>
devapp=>
devapp=> BEGIN; set local enable_seqscan = False; SHOW enable_seqscan; EXPLAIN SELECT * from deletethis where 1 = ANY(col1); COMMIT;
BEGIN
SET
enable_seqscan
----------------
off
(1 row)
QUERY PLAN
-------------------------------------------------------------------------------
Seq Scan on deletethis (cost=10000000000.00..10000000040.60 rows=7 width=32)
Filter: (1 = ANY (col1))
(2 rows)
COMMIT
devapp=>
Why is it still doing Seq Scan and not using the index despite the enable_seqscan
having been set to off
?