1. 18 5月, 2020 1 次提交
  2. 12 5月, 2020 1 次提交
  3. 11 5月, 2020 1 次提交
    • R
      Add `add_binds` to bulk binds processing for performance · 2b35775f
      Ryuta Kamizono 提交于
      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
      ```
      2b35775f
  4. 10 5月, 2020 1 次提交
    • R
      Should not substitute binds when `prepared_statements: true` · 157f6a6e
      Ryuta Kamizono 提交于
      Before IN clause optimization 70ddb8a7, Active Record had generated an
      SQL with binds when `prepared_statements: true`:
      
      ```ruby
      # prepared_statements: true
      #
      #   SELECT `authors`.* FROM `authors` WHERE `authors`.`id` IN (?, ?, ?)
      #
      # prepared_statements: false
      #
      #   SELECT `authors`.* FROM `authors` WHERE `authors`.`id` IN (1, 2, 3)
      #
      Author.where(id: [1, 2, 3]).to_a
      ```
      
      But now, binds in IN clause is substituted regardless of whether
      `prepared_statements: true` or not:
      
      ```ruby
      # prepared_statements: true
      #
      #   SELECT `authors`.* FROM `authors` WHERE `authors`.`id`IN (1,2,3)
      #
      # prepared_statements: false
      #
      #   SELECT `authors`.* FROM `authors` WHERE `authors`.`id`IN (1,2,3)
      #
      Author.where(id: [1, 2, 3]).to_a
      ```
      
      I suppose that is considered as a regression for the context:
      
      > While I would prefer that we fix/avoid the too-many-parameters
      problem, but I don't like the idea of globally ditching bind params for
      this edge case... we're getting to the point where I'd almost consider
      anything that doesn't use a bind to be a bug.
      
      https://github.com/rails/rails/pull/33844#issuecomment-421000003
      
      This makes binds consider whether `prepared_statements: true` or not
      (i.e. restore the original behavior as before), but still gain that
      optimization when need the substitute binds (`prepared_statements: false`,
      `relation.to_sql`). Even when `prepared_statements: true`, it still
      much faster than before by optimized (bind node less) binds generation.
      
      ```ruby
      class Post < ActiveRecord::Base
      end
      
      ids = (1..1000).each.map do |n|
        Post.create!.id
      end
      
      puts "prepared_statements: #{Post.connection.prepared_statements.inspect}"
      
      Benchmark.ips do |x|
        x.report("where with ids") do
          Post.where(id: ids).to_a
        end
      end
      ```
      
      * Before (200058b0)
      
      `prepared_statements: true`:
      
      ```
      Warming up --------------------------------------
            where with ids     6.000  i/100ms
      Calculating -------------------------------------
            where with ids     63.806  (± 7.8%) i/s -    318.000  in   5.015903s
      ```
      
      `prepared_statements: false`:
      
      ```
      Warming up --------------------------------------
            where with ids     7.000  i/100ms
      Calculating -------------------------------------
            where with ids     73.550  (± 8.2%) i/s -    371.000  in   5.085672s
      ```
      
      * Now with this change
      
      `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
      ```
      
      `prepared_statements: false`:
      
      ```
      Warming up --------------------------------------
            where with ids    10.000  i/100ms
      Calculating -------------------------------------
            where with ids    104.335  (± 8.6%) i/s -    520.000  in   5.026425s
      ```
      157f6a6e
  5. 01 1月, 2020 1 次提交
    • K
      Allow #nulls_first and #nulls_last in PostgreSQL · 66b19b5d
      Kevin Deisz 提交于
      When using PostgreSQL, it's useful to be able to specify NULLS FIRST and NULLS LAST on ordered columns. With this commit you can do that now, as in:
      
      ```ruby
      User.arel_table[:first_name].desc.nulls_last
      ```
      66b19b5d
  6. 13 6月, 2019 1 次提交
  7. 19 3月, 2019 2 次提交
    • J
      Remove roflscaling constants · 6fe624f5
      Jeremy Evans 提交于
      6fe624f5
    • J
      Remove roflscaling · 22d82b66
      Jeremy Evans 提交于
      roflscaling (using frozen string constants instead of literal
      strings) was added in 2012, before frozen string literals were
      added in Ruby 2.3.  Now that Rails no longer supports Ruby <2.3,
      and all of these files use frozen string literals, there is
      no reason to keep the roflscaling.
      
      This does not delete or deprecate the related constants. Such
      a change can be made in a later commit.
      22d82b66
  8. 16 11月, 2018 1 次提交
    • D
      Arel: Implemented DB-aware NULL-safe comparison (#34451) · b5302d5a
      Dmytro Shteflyuk 提交于
      * Arel: Implemented DB-aware NULL-safe comparison
      
      * Fixed where clause inversion for NULL-safe comparison
      
      * Renaming "null_safe_eq" to "is_not_distinct_from", "null_safe_not_eq" to "is_distinct_from"
      
      [Dmytro Shteflyuk + Rafael Mendonça França]
      b5302d5a
  9. 28 5月, 2018 1 次提交
  10. 24 2月, 2018 2 次提交