1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/collectors/composite.rb
Ryuta Kamizono 2b35775fbe Add add_binds to bulk binds processing for performance
Before with `prepared_statements: true`:

```
Warming up --------------------------------------
      where with ids     9.000  i/100ms
Calculating -------------------------------------
      where with ids     91.992  (± 7.6%) i/s -    459.000  in   5.020817s
```

Now with `prepared_statements: true`:

```
Warming up --------------------------------------
      where with ids    10.000  i/100ms
Calculating -------------------------------------
      where with ids     99.393  (± 8.0%) i/s -    500.000  in   5.069280s
```
2020-05-11 03:24:49 +09:00

39 lines
693 B
Ruby

# frozen_string_literal: true
module Arel # :nodoc: all
module Collectors
class Composite
attr_accessor :preparable
def initialize(left, right)
@left = left
@right = right
end
def <<(str)
left << str
right << str
self
end
def add_bind(bind, &block)
left.add_bind bind, &block
right.add_bind bind, &block
self
end
def add_binds(binds, &block)
left.add_binds(binds, &block)
right.add_binds(binds, &block)
self
end
def value
[left.value, right.value]
end
private
attr_reader :left, :right
end
end
end