Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Databases
Databasesmedium

Why can `LIKE '%term%'` be slow and what are common alternatives?

Tags
#sql#like#indexes#full-text
Back to categoryPractice quiz

Answer

A leading wildcard (`%term`) often prevents using a normal B-tree index, so the DB may scan many rows. Alternatives include full-text search indexes, trigram indexes (where supported), or changing queries to use prefix search (`term%`) when possible.

Related questions

Databases
What is a covering index (index‑only scan) and why can it be faster?
#database#indexes#covering-index
Databases
Composite index order: why does column order matter?
#database#indexes#composite-index
Databases
Index selectivity: what is it and why does it matter?
#indexes#selectivity#performance
Databases
What is write amplification and why do many indexes make writes slower?
#performance#indexes#write-amplification
Databases
SQL NULL: why is `col = NULL` not true and what should you use?
#sql#null#three-valued-logic
Databases
Why is `SELECT *` risky in production queries?
#sql#best-practices#performance