开发者

Rails 2.3.2 and SHOW TABLES

I have annoying problem with SHOW TABLES in my Rails 2.3.2 APP - it is slowing my APP very deep. The question is, how to get rid of SHOW TABLES usage and where it is used in Rails framework? From APP logs I can see that it is being used all the time.

Thank you!

config/environments/production.rb:

config.cache_classes = true
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching             = true
confi开发者_开发知识库g.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp


"SHOW TABLES" is ORM-dependent SQL query, it fires with every action to provide classes reload in development mode. How much time does the query take?


I was seeing a similar problem in Rails 3.0 and was able to fix it using the gist pointed to from this issue. Looks like it's fixed in Rails 3.2.

I added ar_patch.rb to config/initializers with this code:

unless Rails.env.development?
  require "active_record/connection_adapters/mysql2_adapter"

  module ActiveRecord
    module ConnectionAdapters
      class Mysql2Adapter < AbstractAdapter
        extend ActiveSupport::Memoizable
        memoize :tables, :pk_and_sequence_for, :columns
      end
    end
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜