MySQL – Create Table for Each User Account or One Huge Table?

MySQL

I'm creating a web directory that will allow individual users to signup for an account and store essentially text documents in a mysql database entry.

Initially there will likely be only a few hundred users, but we hope to have 10,000 to 100,000 at some point. And each user would be able to upload 100-200 "documents".

Would it be more efficient to create one massive table, indexed by a user number? Which could theoretically grow to be 20,000,000 entries. Or to go ahead and create a table for each user with their individual documents?

I'm assuming it's not healthy to have thousands of tables in a database, but I really can't find any concrete data on this.

Best Answer

MySQL can easily cope with 20M rows if it's properly indexed. We have tables with more than a billion rows in it.

Having one table is cleaner. Don't need to do magic in application based the user(name). Easier to make any statistics on the documents table too.

I would definitely go with the one big table approach. If you are concerned about the table (physical) size you should consider partitioning the documents table. http://dev.mysql.com/doc/refman/5.5/en/partitioning-types.html