PERF: Restore memoization when preloading associations.
PERF: Restore memoization when preloading associations.

Benchmark Script

```
require 'active_record'
require 'benchmark/ips'
require 'ruby-prof'
require 'memory_profiler'
require 'byebug'

ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false

ActiveRecord::Schema.define do
  create_table :users, force: true do |t|
    t.string :name, :email
    t.integer :topic_id
    t.timestamps null: false
  end

  create_table :topics, force: true do |t|
    t.string :title
    t.timestamps null: false
  end
end

attributes = {
  name: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
  email: 'foobar@email.com'
}

class Topic < ActiveRecord::Base
  has_many :users
end

class User < ActiveRecord::Base
  belongs_to :topic
end

100.times do
  User.create!(attributes)
end

users = User.first(50)

Topic.create!(title: 'This is a topic', users: users)

Benchmark.ips do |x|
  x.config(time: 10, warmup: 5)

  x.report("preload") do
    User.includes(:topic).all.to_a
  end
end
```

Before

```
Calculating -------------------------------------
             preload    26.000  i/100ms
-------------------------------------------------
             preload    265.347  (± 3.0%) i/s -      2.652k
```

After

```
Calculating -------------------------------------
             preload    39.000  i/100ms
-------------------------------------------------
             preload    406.053  (± 1.7%) i/s -      4.095k
```

tjschuck/rails,felipecvo/rails,baerjam/rails,mohitnatoo/rails,kddeisz/rails,aditya-kapoor/rails,yahonda/rails,Vasfed/rails,prathamesh-sonpatki/rails,tgxworld/rails,yahonda/rails,yasslab/railsguides.jp,bogdanvlviv/rails,Edouard-chin/rails,lcreid/rails,assain/rails,starknx/rails,vipulnsward/rails,mechanicles/rails,fabianoleittes/rails,schuetzm/rails,mohitnatoo/rails,joonyou/rails,tjschuck/rails,kddeisz/rails,gauravtiwari/rails,yalab/rails,Erol/rails,iainbeeston/rails,yhirano55/rails,utilum/rails,illacceptanything/illacceptanything,starknx/rails,vipulnsward/rails,notapatch/rails,joonyou/rails,felipecvo/rails,esparta/rails,yawboakye/rails,georgeclaghorn/rails,rafaelfranca/omg-rails,MSP-Greg/rails,Envek/rails,iainbeeston/rails,kirs/rails-1,baerjam/rails,illacceptanything/illacceptanything,yasslab/railsguides.jp,yalab/rails,illacceptanything/illacceptanything,brchristian/rails,illacceptanything/illacceptanything,joonyou/rails,illacceptanything/illacceptanything,fabianoleittes/rails,deraru/rails,pvalena/rails,kmcphillips/rails,illacceptanything/illacceptanything,BlakeWilliams/rails,flanger001/rails,rafaelfranca/omg-rails,vipulnsward/rails,odedniv/rails,gauravtiwari/rails,odedniv/rails,pvalena/rails,lcreid/rails,flanger001/rails,printercu/rails,flanger001/rails,rafaelfranca/omg-rails,kirs/rails-1,prathamesh-sonpatki/rails,aditya-kapoor/rails,palkan/rails,arunagw/rails,vipulnsward/rails,repinel/rails,printercu/rails,esparta/rails,illacceptanything/illacceptanything,assain/rails,fabianoleittes/rails,Stellenticket/rails,mohitnatoo/rails,esparta/rails,tgxworld/rails,gauravtiwari/rails,bogdanvlviv/rails,travisofthenorth/rails,yawboakye/rails,Envek/rails,gfvcastro/rails,kddeisz/rails,flanger001/rails,tgxworld/rails,kirs/rails-1,gfvcastro/rails,Edouard-chin/rails,bogdanvlviv/rails,mechanicles/rails,georgeclaghorn/rails,repinel/rails,arunagw/rails,lcreid/rails,joonyou/rails,pvalena/rails,gfvcastro/rails,prathamesh-sonpatki/rails,iainbeeston/rails,shioyama/rails,rails/rails,yawboakye/rails,Erol/rails,eileencodes/rails,fabianoleittes/rails,felipecvo/rails,illacceptanything/illacceptanything,Vasfed/rails,eileencodes/rails,brchristian/rails,bogdanvlviv/rails,betesh/rails,illacceptanything/illacceptanything,mechanicles/rails,untidy-hair/rails,notapatch/rails,illacceptanything/illacceptanything,mohitnatoo/rails,EmmaB/rails-1,printercu/rails,MSP-Greg/rails,utilum/rails,palkan/rails,Stellenticket/rails,iainbeeston/rails,notapatch/rails,tjschuck/rails,yahonda/rails,kmcphillips/rails,deraru/rails,kmcphillips/rails,Erol/rails,yhirano55/rails,travisofthenorth/rails,printercu/rails,illacceptanything/illacceptanything,tgxworld/rails,rails/rails,illacceptanything/illacceptanything,shioyama/rails,starknx/rails,illacceptanything/illacceptanything,untidy-hair/rails,prathamesh-sonpatki/rails,Vasfed/rails,gfvcastro/rails,betesh/rails,travisofthenorth/rails,mechanicles/rails,MSP-Greg/rails,yasslab/railsguides.jp,Envek/rails,schuetzm/rails,yasslab/railsguides.jp,repinel/rails,BlakeWilliams/rails,repinel/rails,kamipo/rails,Edouard-chin/rails,tjschuck/rails,shioyama/rails,jeremy/rails,jeremy/rails,arunagw/rails,illacceptanything/illacceptanything,georgeclaghorn/rails,pvalena/rails,odedniv/rails,schuetzm/rails,BlakeWilliams/rails,Stellenticket/rails,EmmaB/rails-1,deraru/rails,betesh/rails,jeremy/rails,notapatch/rails,BlakeWilliams/rails,rails/rails,brchristian/rails,georgeclaghorn/rails,kamipo/rails,yhirano55/rails,palkan/rails,EmmaB/rails-1,shioyama/rails,kddeisz/rails,kamipo/rails,jeremy/rails,untidy-hair/rails,yahonda/rails,assain/rails,travisofthenorth/rails,Erol/rails,illacceptanything/illacceptanything,betesh/rails,aditya-kapoor/rails,yalab/rails,Vasfed/rails,yalab/rails,Edouard-chin/rails,deraru/rails,eileencodes/rails,baerjam/rails,arunagw/rails,palkan/rails,Envek/rails,untidy-hair/rails,esparta/rails,rails/rails,lcreid/rails,yhirano55/rails,eileencodes/rails,yawboakye/rails,utilum/rails,baerjam/rails,aditya-kapoor/rails,Stellenticket/rails,schuetzm/rails,MSP-Greg/rails,kmcphillips/rails,assain/rails,utilum/rails