Considering a table as below
CREATE TABLE test (
"a" varchar(32),
"b" varchar(32),
"c" varchar(32),
"d" varchar(32)
);
CREATE INDEX "test_index" ON test USING btree("a", "b", "c");
I need execute queries like
SELECT count(*)
FROM test
WHERE a like 'a%'
and b = 'b'
and c = 'c'
The result of EXPLAIN shows below
Aggregate (cost=10.36..10.37 rows=1 width=0)
-> Index Only Scan using test_index on test (cost=0.14..10.36 rows=1 width=0)
Index Cond: ((b = 'b'::text) AND (c = 'c'::text))
Filter: ((a)::text ~~ 'a%'::text)
Based on the EXPLAIN result from Postgres, only b and c is using index. It seems LIKE 'a%' only works with single column index.
So, how to increase the query speed for the above query?
explain (analyze, buffers)(not just a "simple" explain). Formatted text please, no screen shots or upload the plan to explain.depesz.comSHOW lc_collate?