Do not convert MySQL system tables in the
mysql database from MyISAM
to InnoDB tables! This is an unsupported
operation. If you do this, MySQL does not restart until you
restore the old system tables from a backup or re-generate them
with the mysql_install_db script.
It is not a good idea to configure InnoDB to
use data files or log files on NFS volumes. Otherwise, the files
might be locked by other processes and become unavailable for
use by MySQL.
Maximums and Minimums
Maximums and Minimums
A table cannot contain more than 1000 columns.
The
InnoDBinternal maximum key length is 3500 bytes, but MySQL itself restricts this to 3072 bytes.Index key prefixes can be up to 767 bytes. See Section 12.1.11, “
CREATE INDEXSyntax”.The maximum row length, except for variable-length columns (
VARBINARY,VARCHAR,BLOBandTEXT), is slightly less than half of a database page. That is, the maximum row length is about 8000 bytes.LONGBLOBandLONGTEXTcolumns must be less than 4GB, and the total row length, includingBLOBandTEXTcolumns, 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 13.6.12.2, “File Space Management”.
Although
InnoDBsupports row sizes larger than 65535 internally, you cannot define a row containingVARBINARYorVARCHARcolumns with a combined size larger than 65535:mysql>
CREATE TABLE t (a VARCHAR(8000), b VARCHAR(10000),->c VARCHAR(10000), d VARCHAR(10000), e VARCHAR(10000),->f VARCHAR(10000), g VARCHAR(10000)) ENGINE=InnoDB;ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBsOn some older operating systems, files must be less than 2GB. This is not a limitation of
InnoDBitself, but if you require a large tablespace, you will need to configure it using several smaller data files rather than one or a file large data files.The combined size of the
InnoDBlog files must be less than 4GB.The minimum tablespace size is 10MB. The maximum tablespace size is four billion database pages (64TB). This is also the maximum size for a table.
Index Types
InnoDBtables do not supportFULLTEXTindexes.
Index Types
InnoDBtables support spatial data types, but not indexes on them.
ANALYZE TABLEdetermines index cardinality (as displayed in theCardinalitycolumn ofSHOW INDEXoutput) by doing eight random dives to each of the index trees and updating index cardinality estimates accordingly. Because these are only estimates, repeated runs ofANALYZE TABLEmay produce different numbers. This makesANALYZE TABLEfast onInnoDBtables but not 100% accurate because it does not take all rows into account.The number of random dives can be changed by modifying the
innodb_stats_sample_pagessystem variable. For more information, see Section 13.7.8, “Changes for Flexibility, Ease of Use and Reliability”.MySQL uses index cardinality estimates only in join optimization. If some join is not optimized in the right way, you can try using
ANALYZE TABLE. In the few cases thatANALYZE TABLEdoes not produce values good enough for your particular tables, you can useFORCE INDEXwith your queries to force the use of a particular index, or set themax_seeks_for_keysystem variable to ensure that MySQL prefers index lookups over table scans. See Section 5.1.4, “Server System Variables”, and Section C.5.6, “Optimizer-Related Issues”.
Maximums and Minimums
SHOW TABLE STATUSdoes not give accurate statistics onInnoDBtables, except for the physical size reserved by the table. The row count is only a rough estimate used in SQL optimization.InnoDBdoes not keep an internal count of rows in a table, because concurrent transactions might “see” different numbers of rows at the same time. To process aSELECT COUNT(*) FROM tstatement,InnoDBscans an index of the table, which takes some time if the index is not entirely in the buffer pool. If your table does not change often, using the MySQL query cache is a good solution. To get a fast count, you have to use a counter table you create yourself and let your application update it according to the inserts and deletes it does.SHOW TABLE STATUSalso can be used if an approximate row count is sufficient. See Section 13.6.14.1, “InnoDBPerformance Tuning Tips”.On Windows,
InnoDBalways stores database and table names internally in lowercase. To move databases in a binary format from Unix to Windows or from Windows to Unix, create all databases and tables using lowercase names.For an
AUTO_INCREMENTcolumn, you must always define an index for the table, and that index must contain just theAUTO_INCREMENTcolumn. InMyISAMtables, theAUTO_INCREMENTcolumn may be part of a multi-column index.While initializing a previously specified
AUTO_INCREMENTcolumn on a table,InnoDBsets an exclusive lock on the end of the index associated with theAUTO_INCREMENTcolumn. In accessing the auto-increment counter,InnoDBuses a specific table lock modeAUTO-INCwhere the lock lasts only to the end of the current SQL statement, not to the end of the entire transaction. Other clients cannot insert into the table while theAUTO-INCtable lock is held; see Section 13.6.5.3, “AUTO_INCREMENTHandling inInnoDB”.When you restart the MySQL server,
InnoDBmay reuse an old value that was generated for anAUTO_INCREMENTcolumn but never stored (that is, a value that was generated during an old transaction that was rolled back).
Index Types
When an
AUTO_INCREMENTinteger column runs out of values, a subsequentINSERToperation returns a duplicate-key error. This is general MySQL behavior, similar to howMyISAMworks.DELETE FROMdoes not regenerate the table but instead deletes all rows, one by one.tbl_nameUnder some conditions,
TRUNCATEfor antbl_nameInnoDBtable is mapped toDELETE FROM. See Section 12.1.27, “tbl_nameTRUNCATE TABLESyntax”.In MySQL 5.5, the MySQL
LOCK TABLESoperation acquires two locks on each table ifinnodb_table_locks = 1(the default). In addition to a table lock on the MySQL layer, it also acquires anInnoDBtable lock. Older versions of MySQL did not acquireInnoDBtable locks; the old behavior can be selected by settinginnodb_table_locks = 0. If noInnoDBtable lock is acquired,LOCK TABLEScompletes even if some records of the tables are being locked by other transactions.All
InnoDBlocks held by a transaction are released when the transaction is committed or aborted. Thus, it does not make much sense to invokeLOCK TABLESonInnoDBtables inautocommit = 1mode, because the acquiredInnoDBtable locks would be released immediately.
Sometimes it would be useful to lock further tables in the course of a transaction. Unfortunately,
LOCK TABLESin MySQL performs an implicitCOMMITandUNLOCK TABLES. AnInnoDBvariant ofLOCK TABLEShas been planned that can be executed in the middle of a transaction.The default database page size in
InnoDBis 16KB. By recompiling the code, you can set it to values ranging from 8KB to 64KB. You must update the values ofUNIV_PAGE_SIZEandUNIV_PAGE_SIZE_SHIFTin theuniv.isource file.NoteChanging the page size is not a supported operation and there is no guarantee that
InnoDBwill function normally with a page size other than 16KB. Problems compiling or running InnoDB may occur. In particular,ROW_FORMAT=COMPRESSEDin theInnoDB Pluginassumes that the page size is at most 16KB and uses 14-bit pointers.A version of
InnoDBbuilt for one page size cannot use data files or log files from a version built for a different page size.Currently, cascaded foreign key actions do not activate triggers.
You cannot create a table with a column name that matches the name of an internal InnoDB column (including
DB_ROW_ID,DB_TRX_ID,DB_ROLL_PTR, andDB_MIX_ID). The server reports error 1005 and refers to error –1 in the error message. This limitation applies only to use of the names in uppercase.The limit of 1023 concurrent data-modifying transactions has been raised in MySQL 5.5 and above. The limit is now 128 * 1023 concurrent transactions that generate undo records. You can remove any workarounds that require changing the proper structure of your transactions, such as committing more frequently or delaying DML operations to the end of a transaction.