Skip to content
Browse files

Perf: fields in pg gem causes an allocation, cache it

  • Loading branch information...
1 parent e453aa9 commit 32b233c95315f637a944a1a8f41cb188a452e859 @SamSaffron SamSaffron committed Aug 27, 2013
View
5 activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
@@ -139,7 +139,8 @@ def exec_query(sql, name = 'SQL', binds = [])
exec_cache(sql, binds)
types = {}
- result.fields.each_with_index do |fname, i|
+ fields = result.fields
+ fields.each_with_index do |fname, i|
ftype = result.ftype i
fmod = result.fmod i
types[fname] = OID::TYPE_MAP.fetch(ftype, fmod) { |oid, mod|
@@ -148,7 +149,7 @@ def exec_query(sql, name = 'SQL', binds = [])
}
end
- ret = ActiveRecord::Result.new(result.fields, result.values, types)
+ ret = ActiveRecord::Result.new(fields, result.values, types)
result.clear
return ret
end

0 comments on commit 32b233c

Please sign in to comment.
Something went wrong with that request. Please try again.