This question already has an answer here:
I am using PostgreSQL 9.4 and having tough time with slow queries. Some of these use "like" and others use "not like" searches. For
like searches I could resolve by using trigram indexes, but those with
not like are a headache.
select * from mytable where user_code not like 'TE%'
EXPLAIN ANALYZE says "Seq scan". How can I make Postgres use index in such cases?