What is the maximum size for a MySQL table? Is it 2 million at 50GB? 5 million at 80GB?
At the higher end of the size scale, do I need to think about compressing the data? Or perhaps splitting the table if it grew too big?
我曾经使用过一个非常大的(Terabyte+)MySQL 数据库。我们拥有的最大的表实际上超过了 10 亿行。
有效。MySQL 大部分时间都正确处理了数据。虽然它非常笨拙。
仅备份和存储数据是一项挑战。如果我们需要,恢复表需要几天时间。
我们有许多在 10-1 亿行范围内的表。对表的任何重要连接都太费时了,而且需要很长时间。因此,我们编写了存储过程来“遍历”表并针对“id”范围处理连接。通过这种方式,我们一次处理 10-100,000 行数据(加入 id 的 1-100,000 然后 100,001-200,000 等)。这比加入整个表要快得多。
在不基于主键的非常大的表上使用索引也更加困难。Mysql 将索引存储为两部分——它将索引(除了主索引)存储为主键值的索引。因此索引查找分两部分完成:首先 MySQL 进入索引并从中提取它需要查找的主键值,然后对主键索引进行第二次查找以查找这些值在哪里。
这样做的结果是,对于非常大的表(1-2 亿多行),针对表的索引更具限制性。您需要更少、更简单的索引。即使是不直接在索引上的简单选择语句也可能永远不会回来。Where 子句必须命中索引或忘记它。
但话虽如此,事情确实奏效了。我们能够将 MySQL 与这些非常大的表一起使用,并进行计算并得到正确的答案。
About your first question, the effective maximum size for the database is usually determined by operating system, specifically the file size MySQL Server will be able to create, not by MySQL Server itself. Those limits play a big role in table size limits. And MyISAM works differently from InnoDB. So any tables will be dependent on those limits.
If you use InnoDB you will have more options on manipulating table sizes, resizing the tablespace is an option in this case, so if you plan to resize it, this is the way to go. Give a look at The table is full error page.
I am not sure the real record quantity of each table given all necessary information (OS, Table type, Columns, data type and size of each and etc...) And I am not sure if this info is easy to calculate, but I've seen simple table with around 1bi records in a couple cases and MySQL didn't gave up.