The best way to use the MySQL clause is "Use index ('index_name')" using ActiveRecord

I want to use the SQL sentence "Use index ('index_name')" in an ActiveRecord query, does anyone know a good way to do this with Activerecord I would like to avoid adding a row directly to the query.

+5
source share
1 answer

I use this in my models:

def self.use_index(index)
  from("#{self.table_name} USE INDEX(#{index})")
end
+2
source

All Articles