+ # limit_database_read ensures @objects (which must be an
+ # ActiveRelation) does not return too many results to fit in memory,
+ # by previewing the results and calling @objects.limit() if
+ # necessary.
+ def limit_database_read(model_class:)
+ return if @limit == 0 || @limit == 1
+ model_class ||= self.model_class
+ limit_columns = model_class.limit_index_columns_read