2011-07-21 53 views
0

我的Rails 2.3.2 APP中的SHOW TABLES令人讨厌的问题 - 它会让我的APP变得非常缓慢。问题是,如何摆脱SHOW TABLES的用法以及它在Rails框架中的用处?从APP日志中我可以看到它一直在使用。Rails 2.3.2和SHOW TABLES

谢谢!

配置/环境/ production.rb:

config.cache_classes = true 
config.action_controller.consider_all_requests_local = false 
config.action_controller.perform_caching    = true 
config.action_mailer.raise_delivery_errors = true 
config.action_mailer.delivery_method = :smtp 

回答

0

“SHOW TABLES” 是ORM相关的SQL查询语句,它的每一个动作射击提供课程开发模式重装。查询需要多长时间?

+0

同样的问题进行生产。查询大约为12.5 ms或更多。它每次动作有时会拍摄4-5次。 – thesis

+0

它是每张桌子拍摄的。你的config/environments/production.rb代码是什么? – Anatoly

+0

您可以检查生产服务器上的环境是什么,用于服务应用程序的是什么?该文件是否为空**/log/production.log **? – Anatoly

0

我在Rails 3.0中看到类似的问题,并且能够使用指向this issuegist来修复它。看起来它已经在Rails 3.2中修复了。

我加ar_patch.rb到配置/初始化与此代码:

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