Here is the complete table definition:
CREATE TABLE search.tablename
(
id integer NOT NULL,
name character varying(300) NOT NULL,
CONSTRAINT tablename_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
CREATE INDEX tablename_name_idx
ON search.tablename
USING btree
(name COLLATE pg_catalog."default");
It has ~73k rows and was just vacuumed/analyzed by manual run.
What I cannot understand is why this trivial query
SELECT *
FROM "tablename" AS "arn"
WHERE arn.name LIKE 'foo%'
does not use the corresponding index.
The execution plan for this query is
Seq Scan on tablename arn (cost=0.00..1626.96 rows=7 width=47) (actual time=8.682..8.682 rows=0 loops=1)
Filter: ((name)::text ~~ 'foo%'::text)
Rows Removed by Filter: 73197
Total runtime: 8.703 ms
Could anyone point to what I am missing?
UPD: changing column name type to text changes nothing.
UPD 2: name = 'foo' predicate expectedly uses index