# Multiple DBs and Query Cache

**URL:** <https://www.ruby-forum.com/t/multiple-dbs-and-query-cache/161364>\
**Category:** Rails\
**Created:** [February 25, 2009, 9:42pm UTC](https://www.ruby-forum.com/t/multiple-dbs-and-query-cache/161364 "2009-02-25T21:42:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [February 25, 2009, 9:42pm UTC](https://www.ruby-forum.com/t/multiple-dbs-and-query-cache/161364/1 "2009-02-25T21:42:26Z")

</div>

Hi all,

I have an application where the majority of models live in one main  
DB, while I have a couple model relying on data in a old DB.

So I created an abstract class for those models and called  
establish\_connection() to the old DB. So far so good.

I’m running some fairly repetitive queries and I noticed that some of  
them were taking an excessively long time. After some digging, it  
turns out that query\_cache\_enabled is false for all the models that  
use my newly established connection. The models that use AR::Base’s  
connection work fine with the query cache.

Anybody know how to turn on query caching when you establish a new  
connection?

Rails 2.2.2

Thanks,

Andrew
