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
  • 426,620
  • 70
  • 833
  • 800
2ank3th
  • 2,948
  • 2
  • 21
  • 35

1 Answers1

0

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

Fede Bonisconti
  • 494
  • 4
  • 10