LIKE '%term%' needs a trigram index
A B-tree cannot help a pattern that starts with a wildcard, so WHERE name LIKE '%acme%' scans the table. The trigram extension indexes three-letter chunks and makes it an index scan.
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX customers_name_trgm ON customers USING gin (name gin_trgm_ops);Same index serves ILIKE and similarity search. For real full text search use tsvector. For "find the row whose name contains this", trigrams.
postgresqlsearch