title: Rails multiple database sessions, any drawbacks?
body: <p>I have and app where I'm providing predictive input for postal codes of several countries.
  As you can imagine there's plenty of data that needs to be stored to do that.</p>
  
  <p>I'm using different databases to store the data of several countries. As I support more countries the number of DBs will grow. I'm storing them in mongodb via mongoid.</p>
  
  <p>This is how I do it:</p>
  
  <pre><code>class France_codes
      include Mongoid::Document
      store_in session: "db_south_europe"
  end
  </code></pre>
  
  <p>That session is defined in mongoid.yml</p>
  
  <pre><code>production:
      sessions:
          default:
              uri: "mongodb://...."
  
          db_south_europe:
              uri: "mongodb://...."
  
          db_north_europe:
              uri: "mongodb://...."
  </code></pre>
  
  <p>To select one of the connections.
  I get the country name and make it a constant so I can use its methods. </p>
  
  <pre><code>p = (country+"_codes").constantize
  results = p.where(:cp =&gt; /^#{prefix}/).pluck(:pl)
  </code></pre>
  
  <p>I haven't see any issues with it so far. But I am about to add another DB to the system. I have 7 right now...</p>
  
  <p>The question is:</p>
  
  <p>Is it bad to have several DB sessions ready for use set up this way? Or is this acceptable?
  Mainly thinking about memory footprint, performance, etc. 
  These databases are externally hosted, I'm so far running it at Heroku. We are talking about reads from the DB in this case, nothing is ever written to those DBs from the application. Though I have some other DBs which are used to store data and setup in the same way.</p>
  
  <p>Thanks.</p>