# Large Mysql Database (Multiple Databases?)

**URL:** <https://www.ruby-forum.com/t/large-mysql-database-multiple-databases/165861>\
**Category:** Rails\
**Created:** [April 18, 2009, 5:18pm UTC](https://www.ruby-forum.com/t/large-mysql-database-multiple-databases/165861 "2009-04-18T17:18:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 18, 2009, 5:18pm UTC](https://www.ruby-forum.com/t/large-mysql-database-multiple-databases/165861/1 "2009-04-18T17:18:32Z")

</div>

Hey Everyone,

I’m looking for some advice. I am developing an application that will  
have several million transaction records. I’ve heard of people scaling  
Rails to connect to multiple databases. I have never done this, and  
I’m wondering if rails can look at multiple databases and treat them  
as one, or if I design some sort of overload feature that makes it  
trickle from one database to the next. In essence I don’t want my  
rails application to be limited by database capability or size. As I  
said before I have never designed an app like this, and I want to get  
it right before I get too far into the application. I have just  
started the coding, and would like to be proactive on making the right  
decision.

Thanks!

Chris

---

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 18, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/large-mysql-database-multiple-databases/165861/2 "2009-04-18T18:25:58Z")

</div>

You’ll probably want to look at replication [1] and/or sharding. There  
are several gems out there that will help you do one, the other, or both  
within Rails. I haven’t used any of them, but some quick googling seem  
to indicate that data\_fabric [2] or masochism [3] might be good places  
to start.

While googling I also ran across MySQL’s HA/Scalability Guide which  
looks useful if this is something new to you.

dwh

[1] [http://dev.mysql.com/doc/refman/5.1/en/replication-solutions.html](http://dev.mysql.com/doc/refman/5.1/en/replication-solutions.html)  
[2] [http://blog.fiveruns.com/2008/7/9/introducing-data\_fabric](http://blog.fiveruns.com/2008/7/9/introducing-data_fabric)  
[3] [GitHub - technoweenie/masochism: ActiveRecord connection proxy for master/slave connections](http://github.com/technoweenie/masochism/tree/master) [technoweenie  
always chooses the best project names…]  
[4] [http://dev.mysql.com/doc/mysql-ha-scalability/en/index.html](http://dev.mysql.com/doc/mysql-ha-scalability/en/index.html)

---

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 18, 2009, 8:52pm UTC](https://www.ruby-forum.com/t/large-mysql-database-multiple-databases/165861/3 "2009-04-18T20:52:03Z")

</div>

internetchris wrote:  
[…]

> In essence I don’t want my  
> rails application to be limited by database capability or size.

I would think that it would be better to have the DB take care of the  
multi-DB splitting, and have it appear to the Rails app as one DB.

> As I  
> said before I have never designed an app like this, and I want to get  
> it right before I get too far into the application. I have just  
> started the coding, and would like to be proactive on making the right  
> decision.

The right decision would almost certainly _not_ be to use mySQL.  
PostgreSQL is generally more capable and faster. It’s also more  
extensible.

> Thanks!
> 
> Chris

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![internetchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c68b51/32.png) [@internetchris](https://www.ruby-forum.com/u/internetchris)\
**Post date:** [April 19, 2009, 5:57am UTC](https://www.ruby-forum.com/t/large-mysql-database-multiple-databases/165861/4 "2009-04-19T05:57:05Z")

</div>

I appreciate your replys, I will look into PostgreSQL a little futher.  
A post from yesterday indicated alot of success with PostgreSQL, so I  
will probably go with it. One other thing…

I’m pretty new to rails, and this question may seem ridiculous, but I  
must ask. If I keep my fields the same in my migration, and simply  
change my database.yml file will my views and controllers still work  
fine? I haven’t done alot of development on this app yet, but anytime  
I can avoid rewriting code it’s nice.

Thanks!

Chris

On Apr 18, 12:52 pm, Marnen Laibow-Koser \<rails-mailing-l…@andreas-
