Currently there is no way to disable logging of this query - all SQL
queries are logged in development mode.
And in development mode model classes are reloaded for each request
and therefore during each request processing SQL query is made to get
all table columns for each used model.
There is one "monkey patch" that we use in some our projects that
disables reloading of column information during each request:
### put this in lib/cache_columns.rb
module ActiveRecord
module ConnectionAdapters
class OracleEnhancedAdapter < AbstractAdapter
# Cache column descriptions between requests
@@cache_columns = false
cattr_accessor :cache_columns
def columns_with_cache(table_name, name = nil)
# Don't double cache if config.cache_classes is turned on
if self.class.cache_columns && !(defined?(Rails) &&
Rails.configuration.cache_classes)
@@columns_cache ||= {}
@@columns_cache[table_name] ||= columns_without_cache
(table_name, name)
else
columns_without_cache(table_name, name)
end
end
alias_method_chain :columns, :cache
end
end
end
### include this in some initializer file, e.g. config/initializers/
oracle.rb
# Cache column descriptions between requests
if RAILS_ENV == 'development'
require "cache_columns"
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns
= true
end
As a result table column information will be cached between requests
in development mode and you will not see SELECTs from all_tabs_columns
for each request. This will also speed up a little bit performance in
development mode (especially if Oracle database in development
environment is not on your local machine). But if you change table
columns then you will need to restart Rails application.
Probably I need to add this to the next version of oracle_enhanced.
Raimonds