方法
实例公共方法
exec_queries() 链接
当此模块预先添加至 ActiveRecord::Relation
且 config.active_record.warn_on_records_fetched_greater_than
设置为整数时,如果查询返回的记录数大于 warn_on_records_fetched_greater_than
的值,则会记录一个警告。这允许检测返回大量记录的查询,这可能会导致内存膨胀。
在大多数情况下,可以使用 ActiveRecord::Batches
方法高效地获取大量记录。有关更多信息,请参见 ActiveRecord::Batches
。
来源:显示 | 在 GitHub 上
# File activerecord/lib/active_record/relation/record_fetch_warning.rb, line 16 def exec_queries QueryRegistry.reset super.tap do |records| if logger && ActiveRecord.warn_on_records_fetched_greater_than if records.length > ActiveRecord.warn_on_records_fetched_greater_than logger.warn "Query fetched #{records.size} #{@klass} records: #{QueryRegistry.queries.join(";")}" end end end end