{"push_id":2851902943,"size":1,"distinct_size":1,"ref":"refs/heads/in_clause_length_at_database_yml","head":"50c4f4a896bffcb760ee8eaf7f5625b55db11579","before":"5d432d7b911ab543779d33f8454cce1dbd63ed41","commits":[{"sha":"50c4f4a896bffcb760ee8eaf7f5625b55db11579","author":{"name":"Yasuo Honda","email":"815806a5fcba2cb411d0f70b662adf0091c5dee5@gmail.com"},"message":"MySQL 5.7 introduces `range_optimizer_max_mem_size` to control memory usage for range access method.\nIt sometimes changes execution plans of SQL statements with a large number of in clause, like 10000 from index range scan to full table scan.\n\n\"Limiting Memory Use for Range Optimization\"\nhttps://dev.mysql.com/doc/refman/5.7/en/range-optimization.html#range-optimization-memory-use\n\n> If the specified limit is about to be exceeded, the range access method is abandoned and other methods, including a full table scan, are considered instead.\n\nInstead of changing `range_optimizer_max_mem_size` value at MySQL server,\nsetting `in_clause_length` in Rails splits large in clause into smaller in list.\n\nAs of right now, `in_clause_length` can be configured as follows.\n\n* Quote from @kamipo blog article https://blog.kamipo.net/entry/2017/12/23/230514 in Japanese\n\n```ruby\nActiveSupport.on_load(:active_record) do\n  module ActiveRecord\n    module ConnectionAdapters\n      module DatabaseLimitsExt\n        def in_clause_length\n          1000\n        end\n      end\n\n      class AbstractAdapter\n        prepend DatabaseLimitsExt\n      end\n    end\n  end\nend\n```\n\nThis commit enables to configure `in_clause_length` value in the database.yml file.\n\n* database.yml\n\n```\nproduction:\n  adapter: mysql2\n  in_clause_length: 1000\n```\n\n`in_clause_length` has been useful for Oracle enhanced adapter since Oracle database has a limit to allow the number of in list to 1000.\nThis parameter is not limited to MySQL. I have not found use cases for PostgreSQL and SQLite databases, though.","distinct":true,"url":"https://api.github.com/repos/yahonda/rails/commits/50c4f4a896bffcb760ee8eaf7f5625b55db11579"}]}
{"actor":{"display_login":"yahonda"}}