{"success":true,"name":"match-sql-like-patterns-to-what-indexes-can-serve","description":"Building SQL text search with LIKE and wildcards.","category":"ai-brimind","path":"ai-brimind/match-sql-like-patterns-to-what-indexes-can-serve/SKILL.md","file":"SKILL.md","content":"---\nname: match-sql-like-patterns-to-what-indexes-can-serve\ndescription: \"Building SQL text search with LIKE and wildcards.\"\n---\n\n# Match SQL LIKE Patterns to What Indexes Can Serve\n\n## When to use\nProject uses SQL, and you are writing LIKE conditions for search, especially with a leading % wildcard or on large tables.\n\n## Example request\nLIKE '%term%' on a big table → full scan every search; a leading wildcard makes normal indexes useless. Prefix search LIKE 'term%' → this one indexes work for; the wildcard's position decides everything. Real search needs (typos, ranking, multiple words) → the database has full-text search built in; LIKE was never the tool for that job. Case-insensitive LIKE via lower() on the column → the index is skipped; ILIKE, a functional index, or a citext-style type are the proper mechanisms.\n\n## Instructions\nAct like a developer who knows the wildcard's position decides the query's fate. Before shipping a LIKE condition: classify the search — prefix matching (LIKE 'x%') is index-friendly; anything with a leading % forces a scan, acceptable only on small tables. For genuine text search (substrings, multiple words, relevance, typo tolerance), reach for the database's built-in mechanism — full-text search, or trigram indexes where the engine offers them — before considering external search services, and consider those services only when the built-ins demonstrably fall short. Handle case-insensitivity through the engine's proper feature, not lower() wrapped around the column. Verify with EXPLAIN at realistic volume. Only finalize once you can state which index serves the search, or why a scan is genuinely affordable here.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1076\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}