Skip to content

Latest commit

 

History

History
111 lines (57 loc) · 11.1 KB

14.23_innodb-limits.md

File metadata and controls

111 lines (57 loc) · 11.1 KB

14.23 InnoDB Limits

14.23 一些InnoDB的最大值限制

This section describes limits for InnoDB tables, indexes, tablespaces, and other aspects of the InnoDB storage engine.

  • A table can contain a maximum of 1017 columns (raised in MySQL 5.6.9 from the earlier limit of 1000). Virtual generated columns are included in this limit.

  • A table can contain a maximum of 64 secondary indexes.

本节描述 InnoDB 存储引擎的一些限制, 包括表,索引,表空间以及其他方面。

  • 从 MySQL5.6.9 开始, InnoDB 中, 一个表最多可以有 1017 个列; 之前则是最多1000列。 虚拟生成列也包含在这个限制中。

  • 一个表最多可以包含64个二级索引(secondary indexes).

  • If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes for InnoDB tables that use the DYNAMIC or COMPRESSED row format. If innodb_large_prefix is disabled, the index key prefix limit is 767 bytes for tables of any row format.

  • 如果启用 innodb_large_prefix,则 DYNAMIC 或者 COMPRESSED 行格式的InnoDB表, 索引前缀限制为 3072 个字节, 默认值是启用状态。 如果禁用 innodb_large_prefix, 则每一种行格式的索引前缀都限制为 767 字节。

    innodb_large_prefix is deprecated; expect it to be removed in a future MySQL release. innodb_large_prefix was introduced in MySQL 5.5 to disable large index key prefixes for compatibility with earlier versions of InnoDB that do not support large index key prefixes.

    The index key prefix length limit is 767 bytes for InnoDB tables that use the REDUNDANT or COMPACT row format. For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a utf8mb3 character set and the maximum of 3 bytes for each character.

    innodb_large_prefix 选项已弃用; 在将来的MySQL版本中可能会将其删除。 这个选项是在MySQL 5.5中引入的,用来禁用大索引前缀,以便与早期版本的 InnoDB 兼容, 因为之前不支持大索引前缀。

    对于使用 REDUNDANT or COMPACT 行格式的InnoDB表,索引前缀长度限制为767个字节。 例如在 TEXT 或者长度大于 255 字符的 VARCHAR 列上创建前缀索引 [column prefix](https://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_column_prefix), 可能就会受到这个限制。 假设使用 utf8mb3` 字符集,恰好每个字符最多占3个字节。

    Attempting to use an index key prefix length that exceeds the limit returns an error. To avoid such errors in replication configurations, avoid enabling innodb_large_prefix on the source if it cannot also be enabled on replicas.

    If you reduce the InnoDB page size to 8KB or 4KB by specifying the innodb_page_size option when creating the MySQL instance, the maximum length of the index key is lowered proportionally, based on the limit of 3072 bytes for a 16KB page size. That is, the maximum index key length is 1536 bytes when the page size is 8KB, and 768 bytes when the page size is 4KB.

    The limits that apply to index key prefixes also apply to full-column index keys.

    尝试使用超出长度限制的前缀索引会报错。 为了避免主从复制中的此类错误, 如果从库不开启的话, 请避免在主库上启用innodb_large_prefix

    如果在启动MySQL服务器实例时通过innodb_page_size 选项将 InnoDB page size 减小到8KB或4KB,那么, 索引的最大长度会按比例降低,根据页面大小为16KB限制3072字节。 即,当页面大小为8KB时,最大索引长度为1536字节,而当页面大小为4KB时,最大索引长度为768字节。

    适用于索引前缀的限制, 也适用于整列索引。

  • A maximum of 16 columns is permitted for multicolumn indexes. Exceeding the limit returns an error.

  • 一个多列索引最多允许包含16列。 超过限制将返回错误。

    ERROR 1070 (42000): Too many key parts specified; max 16 parts allowed
  • The maximum row size, excluding any variable-length columns that are stored off-page, is slightly less than half of a page for 4KB, 8KB, 16KB, and 32KB page sizes. For example, the maximum row size for the default innodb_page_size of 16KB is about 8000 bytes. However, for an InnoDB page size of 64KB, the maximum row size is approximately 16000 bytes. LONGBLOB and LONGTEXT columns must be less than 4GB, and the total row size, including BLOB and TEXT columns, must be less than 4GB.

    If a row is less than half a page long, all of it is stored locally within the page. If it exceeds half a page, variable-length columns are chosen for external off-page storage until the row fits within half a page, as described in Section 14.12.2, “File Space Management”.

  • 对于 4KB,8KB,16KB和32KB 的page size, row size的最大值都小于 page size 的一半, 当然这不包括页面外存储的那些可变长度列。 例如,默认 innodb_page_size 为16KB, 那么最大 row size 大约就是 8000 个字节。 但是,对于64KB的InnoDB页面大小,最大row size约为16000字节。 LONGBLOB and LONGTEXT 列必须小于4GB。 包括BLOB and TEXT列在内, 总的 row size 值也必须小于4GB。

    如果行的长度少于 page 的一半,则所有内容都将存储在页面内。 如果超过 page 的一半,则选择一部分可变长度的列, 使用页外存储来保存,直到该行可以放到半页中,详情参考 Section 14.12.2, “File Space Management”

  • Although InnoDB supports row sizes larger than 65,535 bytes internally, MySQL itself imposes a row-size limit of 65,535 for the combined size of all columns. See Section 8.4.7, “Limits on Table Column Count and Row Size”.

  • On some older operating systems, files must be less than 2GB. This is not an InnoDB limitation. If you require a large system tablespace, configure it using several smaller data files rather than one large data file, or distribute table data across file-per-table and general tablespace data files.

  • The combined maximum size for InnoDB log files is 512GB.

  • The minimum tablespace size is slightly larger than 10MB. The maximum tablespace size depends on the InnoDB page size.

  • 尽管 InnoDB 内部允许超过 65,535 字节的row size,但是 MySQL 本身对所有列的总大小强加了 65,535 的 row-size 限制。 请参考 Section 8.4.7, “Limits on Table Column Count and Row Size”

  • 在某些较老的操作系统上,单个文件的大小不能超过2GB。 这不是 InnoDB 的限制。 如果需要使用很大的系统表空间,这时候就只能使用多个较小的数据文件(而不是一个庞大的数据文件),或者将表和数据分配到 file-per-table 和 常规表空间之中。

  • InnoDB日志文件总的最大值为512GB。

  • 表空间的最小值比10MB大一点点。 表空间的大小, 最大值则取决于InnoDB页面的大小。

    Table 14.25 InnoDB 表空间的最大值

    InnoDB的Page Size 最大表空间
    4KB 16TB
    8KB 32TB
    16KB 64TB
    32KB 128TB
    64KB 256TB

    The maximum tablespace size is also the maximum size for a table.

    表空间的最大值, 也就是单个表的最大值限制。

  • Tablespace files cannot exceed 4GB on Windows 32-bit systems (Bug #80149).

  • The path of a tablespace file, including the file name, cannot exceed the MAX_PATH limit on Windows. Prior to Windows 10, the MAX_PATH limit is 260 characters. As of Windows 10, version 1607, MAX_PATH limitations are removed from common Win32 file and directory functions, but you must enable the new behavior.

  • ROW_FORMAT=COMPRESSED in the Barracuda file format assumes that the page size is at most 16KB and uses 14-bit pointers.

  • For limits associated with concurrent read-write transactions, see Section 14.6.7, “Undo Logs”.

  • 在32位Windows系统上,表空间文件最大不能超过4GB (Bug #80149)。

  • 在Windows上, 表空间文件(包括文件名)的路径长度不能超过的 MAX_PATH 限制。 在 Windows 10 之前,MAX_PATH 的限制为260个字符。 从Windows 10, version 1607开始,已从常见的Win32文件和目录功能中删除了 MAX_PATH 限制,但也必须启用新行为。

  • Barracuda 文件格式中的 ROW_FORMAT=COMPRESSED 假定页面大小最大为16KB,使用 14-bit 指针。

  • 有关并发读写事务的限制,请参考 Section 14.6.7, “Undo Logs”

原文链接

https://dev.mysql.com/doc/refman/5.7/en/innodb-limits.html