2011-07-21 56 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