def each_instance_batch_by_sql(sql, options={}, &block)
        options = {:connection => self.connection}.merge(options)
        cursor  = PostgreSQLCursor::Cursor.new(sql, options)
        return cursor.each_instance_batch(self, &block) if block_given?
        cursor.iterate_type(self).iterate_batched
      end
Public: Yields each batch up to block_size of rows as model instances
to the given block

As this instantiates a model object, it is slower than each_row_batch_by_sql

Paramaters: see each_row_by_sql

Example:
Post.each_instance_batch_by_sql("select * from posts") do |batch|
Post.process_batch(batch)
end
Post.each_instance_batch_by_sql("select * from posts").map do |batch|
Post.transform_batch(batch)
end

Returns the number of rows yielded to the block