I have a usernames table with a username string field, I have a "start with" query and trying both pattern and regex matching
SELECT username FROM usernames WHERE username LIKE 'foo%';
SELECT username FROM usernames WHERE username ~ '^foo';
I have a b-tree index on the username field and SET ENABLE_SEQSCAN =false; , When I EXPLAIN the abovementioned queries, the query planner uses SEQ_SCAN (Seq Scan)
I am using PostgreSQL 13.4 , tried VACUUM (VERBOSE, ANALYZE) usernames and REINDEX TABLE usernames too
What's wrong here?
cand the index was not defined with text_pattern_ops: postgresql.org/docs/current/indexes-opclass.htmlLC_COLLATEandLC_CTYPEboth arefa_IRtext_pattern_opssolved the problem :-)