Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many rows are 'too many' for a MySQL table? [duplicate]

Possible Duplicate:
How many rows in a database are TOO MANY?

I am building the database scheme for an application that will have users, and each user will have many rows in relation tables such as 'favorites'. Each user could have thousands of favorites, and there could be thousands of registered users (over time).

Given that users are never deleted, because that would either leave other entities orphaned, or have them deleted too (which isn't desired), and therefore these tables will keep growing forever, I was wondering if the resulting tables could be too big (eg: 1kk rows), and I should worry about this and do something like mark old and inactive users as deleted and remove the relations that only affect them (such as the favorites and other preferences).

Is this the way to go? Or can mysql easily handle 1kk rows in a table? Is there a known limit? Or is it fully hardware-dependant?

like image 842
HappyDeveloper Avatar asked Mar 18 '11 10:03

HappyDeveloper


People also ask

How many rows in MySQL is too much?

The MySQL maximum row size limit of 65,535 bytes is demonstrated in the following InnoDB and MyISAM examples. The limit is enforced regardless of storage engine, even though the storage engine may be capable of supporting larger rows.

Can MySQL have duplicate rows?

MySQL is a database application that stores data in tables in the form of rows and columns. This database application can store duplicate records in the table, which can impact the performance of the database in MySQL.

How many fields is too many in a MySQL table?

MySQL has hard limit of 4096 columns per table, but the effective maximum may be less for a given table.


1 Answers

I agree with klennepette and Brian - with a couple of caveats.

If your data is inherently relational, and subject to queries that work well with SQL, you should be able to scale to hundreds of millions of records without exotic hardware requirements.

You will need to invest in indexing, query tuning, and making the occasional sacrifice to the relational model in the interests of speed. You should at least nod to performance when designing tables – preferring integers to strings for keys, for instance.

If, however, you have document-centric requirements, need free text search, or have lots of hierarchical relationships, you may need to look again.

If you need ACID transactions, you may run into scalability issues earlier than if you don't care about transactions (though this is still unlikely to affect you in practice); if you have long-running or complex transactions, your scalability decreases quite rapidly.

I'd recommend building the project from the ground up with scalability requirements in mind. What I've done in the past is set up a test environment populated with millions of records (I used DBMonster, but not sure if that's still around), and regularly test work-in-progress code against this database using load testing tools like Jmeter.

like image 65
Neville Kuyt Avatar answered Oct 08 '22 01:10

Neville Kuyt