diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-03 11:12:07 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-03 11:12:07 -0800 |
commit | 1a15fda02159487371a0cb4c36311345dec7b46b (patch) | |
tree | 5488c1de8c8916373c969ada01dd74a1758ee737 | |
parent | a5d8f0be006e5b77d9a82b59407c8d0585f87d41 (diff) | |
download | rails-1a15fda02159487371a0cb4c36311345dec7b46b.tar.gz rails-1a15fda02159487371a0cb4c36311345dec7b46b.tar.bz2 rails-1a15fda02159487371a0cb4c36311345dec7b46b.zip |
reduce cache misses on STI subclasses
-rw-r--r-- | activerecord/lib/active_record/base.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index e4a425627f..8750e226b9 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -747,12 +747,13 @@ module ActiveRecord #:nodoc: undefine_attribute_methods reset_column_cache @column_names = @content_columns = @dynamic_methods_hash = @inheritance_column = nil - @arel_engine = @relation = @arel_table = nil + @arel_engine = @relation = nil end def reset_column_cache # :nodoc: @@columns.delete table_name @@columns_hash.delete table_name + @@arel_tables.delete table_name end def attribute_method?(attribute) @@ -851,7 +852,7 @@ module ActiveRecord #:nodoc: end def arel_table - @arel_table ||= Arel::Table.new(table_name, arel_engine) + @@arel_tables[table_name] ||= Arel::Table.new(table_name, arel_engine) end def arel_engine @@ -1401,6 +1402,7 @@ MSG end @@columns_hash = {} @@columns = {} + @@arel_tables = {} public # New objects can be instantiated as either empty (pass no construction parameter) or pre-set with |