简体   繁体   English

MySQL 数据库的最大表大小

[英]Maximum table size for a MySQL database

What is the maximum size for a MySQL table? MySQL 表的最大大小是多少? Is it 2 million at 50GB? 50GB 是 200 万吗? 5 million at 80GB? 80GB 500 万?

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?或者,如果桌子变得太大,可能会拆分桌子?

I once worked with a very large (Terabyte+) MySQL database. 我曾经使用过非常大的(Terabyte +)MySQL数据库。 The largest table we had was literally over a billion rows. 我们拥有的最大的表格实际上超过十亿行。

It worked. 有效。 MySQL processed the data correctly most of the time. MySQL在大多数时间正确处理数据。 It was extremely unwieldy though. 但这非常笨拙。

Just backing up and storing the data was a challenge. 仅备份和存储数据是一项挑战。 It would take days to restore the table if we needed to. 如果需要,恢复表需要数天。

We had numerous tables in the 10-100 million row range. 我们在10-100万行范围内有许多表。 Any significant joins to the tables were too time consuming and would take forever. 表格的任何重要联接都太耗费时间并且需要永远。 So we wrote stored procedures to 'walk' the tables and process joins against ranges of 'id's. 因此,我们编写了存储过程来“遍历”表并处理对'id'范围的连接。 In this way we'd process the data 10-100,000 rows at a time (Join against id's 1-100,000 then 100,001-200,000, etc). 通过这种方式,我们一次处理10-100,000行数据(加入id的1-100,000然后100,001-200,000等)。 This was significantly faster than joining against the entire table. 这比加入整个表格要快得多。

Using indexes on very large tables that aren't based on the primary key is also much more difficult. 在非基于主键的非常大的表上使用索引也要困难得多。 Mysql stores indexes in two pieces -- it stores indexes (other than the primary index) as indexes to the primary key values. Mysql将索引存储为两部分 - 它将索引(主索引除外)存储为主键值的索引。 So indexed lookups are done in two parts: First MySQL goes to an index and pulls from it the primary key values that it needs to find, then it does a second lookup on the primary key index to find where those values are. 因此,索引查找分为两部分:首先MySQL转到索引并从中获取需要查找的主键值,然后在主键索引上进行第二次查找以查找这些值的位置。

The net of this is that for very large tables (1-200 Million plus rows) indexing against tables is more restrictive. 这样做的结果是,对于非常大的表(1-200万加行),对表的索引更具限制性。 You need fewer, simpler indexes. 您需要更少,更简单的索引。 And doing even simple select statements that are not directly on an index may never come back. 即使是不直接在索引上的简单select语句也可能永远不会回来。 Where clauses must hit indexes or forget about it. 哪些条款必须达到索引或忘记它。

But all that being said, things did actually work. 但话说回来,事情确实奏效了。 We were able to use MySQL with these very large tables and do calculations and get answers that were correct. 我们能够将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. 关于第一个问题, 数据库的有效最大大小通常由操作系统决定,特别是MySQL Server能够创建的文件大小,而不是MySQL服务器本身。 Those limits play a big role in table size limits. 这些限制在表格大小限制中起着重要作用。 And MyISAM works differently from InnoDB. MyISAM与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. 如果您使用InnoDB,您将有更多选项来操作表大小,在这种情况下调整表空间大小是一个选项,所以如果您打算调整它的大小,这就是要走的路。 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. 我不确定每个表的真实记录数量给出所有必要的信息(操作系统,表类型,列,数据类型和每个的大小等等)。我不确定这些信息是否易于计算,但我在一些情况下,我看到了简单的表,大约有1bi的记录,而MySQL并没有放弃。

See this http://www.clb4u.com/2013/10/scalability-and-limits-of-mysql.html 请参阅http://www.clb4u.com/2013/10/scalability-and-limits-of-mysql.html

Support for large databases. 支持大型数据库。 We use MySQL Server with databases that contain 50 million records. 我们将MySQL Server与包含5000万条记录的数据库结合使用。 We also know of users who use MySQL Server with 200,000 tables and about 5,000,000,000 rows. 我们也知道使用MySQL服务器的用户有200,000个表和大约5,000,000,000行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM