Avoid retrieving connection in ActiveRecord::QueryCache multiple times.