aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-08-07 09:40:53 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-08-07 09:40:53 -0700
commit69adfc9de6961e368f9023ab1d256affa49e913e (patch)
tree61e42dc793c76cd8ec38af19fe126317f369e84c /activerecord/lib/active_record
parent12cf864abb27d71d2bb3990fe48beb9b606bc223 (diff)
parent4e83815ce991efce2b84aa570f6673227ff0bb0d (diff)
downloadrails-69adfc9de6961e368f9023ab1d256affa49e913e.tar.gz
rails-69adfc9de6961e368f9023ab1d256affa49e913e.tar.bz2
rails-69adfc9de6961e368f9023ab1d256affa49e913e.zip
Merge pull request #16421 from tsukasaoishi/prevant_manycall_showtables
Tables existence check query is executed in large quantities
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/schema_cache.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/schema_cache.rb b/activerecord/lib/active_record/connection_adapters/schema_cache.rb
index 3116bed596..a10ce330c7 100644
--- a/activerecord/lib/active_record/connection_adapters/schema_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/schema_cache.rb
@@ -19,6 +19,7 @@ module ActiveRecord
# A cached lookup for table existence.
def table_exists?(name)
+ prepare_tables if @tables.empty?
return @tables[name] if @tables.key? name
@tables[name] = connection.table_exists?(name)
@@ -82,6 +83,12 @@ module ActiveRecord
def marshal_load(array)
@version, @columns, @columns_hash, @primary_keys, @tables = array
end
+
+ private
+
+ def prepare_tables
+ connection.tables.each { |table| @tables[table] = true }
+ end
end
end
end