how to do? there is an active record option?
A:
You can do it using rails monkey patch:
class ActiveRecord::Base
def self.insert_low_priority(hash)
keys = hash.keys.map { |v| "`#{v}`" }.join(',')
values = hash.values.map { |v| sanitize(v) }.join(',')
connection.insert_sql("INSERT LOW_PRIORITY INTO `#{table_name}` (#{keys}) VALUES(#{values})")
end
end
Add it to the initializers, e.g. config/initializers/activerecord_insert_low_priority.rb
Usage is simple: ModelName.insert_low_priority :column1 => 'value'
Dmitry Polushkin
2010-09-08 13:34:26