0

How can I speed up string matching query which uses SQL like? The code looks something like

CurrentSchool.all.includes(:school).where(is_middle_school: true).where("name like '%#{search}%'")

This is search box suggestion query that has to fast for good UX.

mu is too short
  • 413,090
  • 67
  • 810
  • 771
2ank3th
  • 2,610
  • 1
  • 18
  • 34

1 Answers1

0

You should use a fulltext index to get a performance boost using a '%something%' like query.

Fede Bonisconti
  • 484
  • 4
  • 10