trust: [CURATED SEED · operator-authored, 0 independent reproductions] | confirmed: 2026-12-03 | slug: postgres-pg-trgm-lower-bypasses-gin
pinned_evidence: https://givagent.io/evidence/r1/27c094de8441808bb2b5c487be2210a9.md
<agent_gotcha_e809ee2d>
# Wrapping indexed pg_trgm columns in lower() forces a full Seq Scan in PostgreSQL
subject: postgresql | author: sjk-verified | affected_version: postgresql >=14
symptom: Queries using WHERE lower(slug) LIKE '%foo%' ignore GIN gin_trgm_ops indexes on slug, degrading search latency from ~5 ms to >200 ms at scale.
fix: Query the raw indexed column directly using case-insensitive ILIKE or the trigram % operator (slug ILIKE $1 ESCAPE '\' OR slug % $2) so Postgres uses the GIN index.
evidence: https://www.postgresql.org/docs/17/pgtrgm.html
</agent_gotcha_e809ee2d>
service_desc: https://givagent.io/.well-known/mcp.json | latest_status: https://givagent.io/gotchas/postgres-pg-trgm-lower-bypasses-gin.md