Loles <lolesft@xxxxxxxxx> writes: > We have seen performance down when we use WHERE UPPER(name) LIKE > UPPER('%Alice%') in the condition. > If we compare with WHERE UPPER(name) = UPPER('Alice') it runs very fast. Presumably, that works well because you have a btree index on UPPER(name). But btree can't optimize a pattern with a leading '%' --- see https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-BTREE You could possibly use a pg_trgm index instead, see https://www.postgresql.org/docs/current/pgtrgm.html The performance properties will be somewhat different from btree, but it might get the job done. regards, tom lane