# Advice on performance concerns (MySQL / Number of rows)

**URL:** <https://www.ruby-forum.com/t/advice-on-performance-concerns-mysql-number-of-rows/123115>\
**Category:** Rails\
**Created:** [December 14, 2007, 6:00am UTC](https://www.ruby-forum.com/t/advice-on-performance-concerns-mysql-number-of-rows/123115 "2007-12-14T06:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 14, 2007, 6:00am UTC](https://www.ruby-forum.com/t/advice-on-performance-concerns-mysql-number-of-rows/123115/1 "2007-12-14T06:00:37Z")

</div>

Hi all,

I’m developing a web app that I intend on trying to sell as SaaS  
(Software as a Service (ie Basecamp)).

1. The first thought on my head would be to use one single database,  
and create columns to indicate which client was the owner of that row.  
The main table will be getting somewhere around 50 rows everyday for  
each client. This gives me near 1k rows per month, per client  
(considering only business days + rounding). Considering that I hope I  
can reach say 100 clients, I will be getting 100k rows per month. In  
one year, thats more than 1m rows. I believe that queries on tables  
with 1m rows have a significant slowdown.

2. So the next thought was to create one database per client. Then I  
would have 100 databases in one server, which does not sound that bad.  
To be able to do this and still keep only one codebase, I would need  
to store the database connection parameters in different files. Then  
when someone requires data from xxxx client, xxxx\_dbs.yml is used. Any  
thoughts on that?

3. Also, I could create a mix of both options, where I would have  
client groups (creating groups for every, say, 10 clients), then  
having only 1/10th of the configuration files and 1/10th of the  
databases, but requiring a column on each database to differentiate  
between clients (this sounds hard to implement on app level).

At this point, option number 2 sounds like the best one. Considering  
that my app actually gets useful and sells a lot, reaching, say, 5000  
clients, will the option for 100 clients still be the best one for 5k  
clients?

Do you know how 37signals works regarding this situation?

Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 14, 2007, 7:27am UTC](https://www.ruby-forum.com/t/advice-on-performance-concerns-mysql-number-of-rows/123115/2 "2007-12-14T07:27:00Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hi all,
> 
> I’m developing a web app that I intend on trying to sell as SaaS  
> (Software as a Service (ie Basecamp)).
> 
> 1. The first thought on my head would be to use one single database,  
> and create columns to indicate which client was the owner of that row.  
> The main table will be getting somewhere around 50 rows everyday for  
> each client. This gives me near 1k rows per month, per client  
> (considering only business days + rounding). Considering that I hope I  
> can reach say 100 clients, I will be getting 100k rows per month. In  
> one year, thats more than 1m rows. I believe that queries on tables  
> with 1m rows have a significant slowdown.

this could help you a bit.

> **[Why MySQL Could Be Slow With Large Tables](https://www.percona.com/blog/why-mysql-could-be-slow-with-large-tables/)**
>
> Peter Zaitsev explains how to optimize your MySQL table design & data using Buffers, Indexes and Joins to enable databases to handle large tables efficiently.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 14, 2007, 9:45am UTC](https://www.ruby-forum.com/t/advice-on-performance-concerns-mysql-number-of-rows/123115/3 "2007-12-14T09:45:21Z")

</div>

On 12/14/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all,
> 
> I’m developing a web app that I intend on trying to sell as SaaS  
> (Software as a Service (ie Basecamp)).

_snipped examples of shared vs. separate databases approach_

> At this point, option number 2 sounds like the best one. Considering  
> that my app actually gets useful and sells a lot, reaching, say, 5000  
> clients, will the option for 100 clients still be the best one for 5k  
> clients?

See [http://msdn2.microsoft.com/en-us/library/aa479086.aspx](http://msdn2.microsoft.com/en-us/library/aa479086.aspx).

Isak
