Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
MySQL Tuning, Indexing & Concurrency 5-8 Years (Senior) Medium Production Scenario

How do you optimize `LIKE "%search%"` full string searches on tables with millions of rows without elasticsearch?

Real-World Scenario / Incident Description

Product title searches with leading wildcards (`LIKE "%laptop%"`) could not use regular B+Tree indexes.

61 views • Updated 1 month ago

MySQL FULLTEXT Index with N-Gram Parser

ALTER TABLE products ADD FULLTEXT INDEX ft_title_desc (title, description) WITH PARSER ngram;

-- High performance full text search
SELECT * FROM products
WHERE MATCH(title, description) AGAINST('+laptop +pro' IN BOOLEAN MODE);
Related Concepts: #Fulltext Index #LIKE Search #Performance