|
Spec-Zone .ru
спецификации, руководства, описания, API
|
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.
A table can contain a maximum of 1020 columns. (Raised in MySQL 5.6.9 from the earlier limit of 1000.
A table can contain a maximum of 64 secondary indexes.
By default, an index key for a single-column index can be up to 767 bytes. The same
length limit applies to any index key prefix. See Section
13.1.13, "CREATE INDEX Syntax". 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 UTF-8 character set and the maximum of 3 bytes
for each character. When the innodb_large_prefix configuration option is enabled, this length
limit is raised to 3072 bytes, for InnoDB tables that use the DYNAMIC and COMPRESSED
row formats.
When you attempt to specify an index prefix length longer than allowed, the length is silently
reduced to the maximum length for a nonunique index. For a unique index, exceeding the index prefix
limit produces an error. To avoid such errors for replication configurations, avoid setting the innodb_large_prefix
option on the master if it cannot also be set on the slaves, and the slaves have unique indexes that
could be affected by this limit.
This configuration option changes the error handling for some combinations of row format and prefix
length longer than the maximum allowed. See innodb_large_prefix for details.
The InnoDB internal maximum key length is 3500 bytes,
but MySQL itself restricts this to 3072 bytes. This limit applies to the length of the combined index
key in a multi-column index.
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 maximum row length, except for variable-length columns (VARBINARY, VARCHAR, BLOB and TEXT), is slightly less than half of a database page. That is, the
maximum row length is about 8000 bytes for the default page size of 16KB; if you reduce the page size by
specifying the innodb_page_size option when creating the MySQL instance, the maximum
row length is 4000 bytes for 8KB pages and 2000 bytes for 4KB pages. LONGBLOB and LONGTEXT columns must be less than 4GB, and the total row length,
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 5.3.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:
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 theused table type, not counting BLOBs, is 65535. You have to change somecolumns to TEXT or BLOBs
See Section E.10.4, "Limits on Table Column Count and Row Size".
On some older operating systems, files must be less than 2GB. This is not a
limitation of InnoDB itself, 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 InnoDB log files can be up to
512GB.
The minimum tablespace size is slightly larger than 10MB. The maximum tablespace size is four billion database pages (64TB). This is also the maximum size for a table.
The
default database page size in InnoDB is 16KB, or you can lower the page
size to 8KB or 4KB by specifying the innodb_page_size option when creating the MySQL instance.
Increasing the page size is not a supported operation: there is no guarantee that InnoDB will function normally with a page size greater than 16KB.
Problems compiling or running InnoDB may occur. In particular, ROW_FORMAT=COMPRESSED
in the Barracuda file format assumes that the page size is at most 16KB and uses 14-bit
pointers.
A MySQL instance using a particular InnoDB page size
cannot use data files or log files from an instance that uses a different page size. This
limitation could affect restore or downgrade operations using data from MySQL 5.6, which does
support page sizes other than 16KB.
InnoDB tables support FULLTEXT indexes, starting in MySQL 5.6.4. See Section
14.2.3.12.3, "FULLTEXT Indexes" for details.
InnoDB tables support spatial data types, but not
indexes on them.
ANALYZE TABLE
determines index cardinality (as displayed in the Cardinality column of SHOW INDEX output) by doing random dives
to each of the index trees and updating index cardinality estimates accordingly. Because these are only
estimates, repeated runs of ANALYZE
TABLE could produce different numbers. This makes ANALYZE TABLE fast on InnoDB tables but
not 100% accurate because it does not take all rows into account.
You can make the statistics collected by ANALYZE TABLE more precise and more stable by turning on the innodb_stats_persistent
configuration option, as explained in Section
14.2.4.2.10, "Persistent Optimizer Statistics for InnoDB Tables". When that setting is
enabled, it is important to run ANALYZE
TABLE after major changes to indexed column data, because the statistics are not
recalculated periodically (such as after a server restart) as they traditionally have been.
You can change the number of random dives by modifying the innodb_stats_persistent_sample_pages system variable (if the
persistent statistics setting is turned on), or the innodb_stats_transient_sample_pages system variable (if the
persistent statistics setting is turned off). For more information, see Section
14.2.5, "InnoDB Features 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 that ANALYZE TABLE does not produce values good enough for your
particular tables, you can use FORCE INDEX with your queries to force
the use of a particular index, or set the max_seeks_for_key system 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".
SHOW TABLE
STATUS does not give accurate statistics on InnoDB tables,
except for the physical size reserved by the table. The row count is only a rough estimate used in SQL
optimization.
InnoDB does 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 a SELECT COUNT(*) FROM
t statement, InnoDB scans 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. If an
approximate row count is sufficient, SHOW TABLE STATUS can be used. See Section
14.2.4.1, "InnoDB Performance Tuning Tips".
On Windows, InnoDB always 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.
An AUTO_INCREMENT column ai_col must be defined as part of an index such that it is
possible to perform the equivalent of an indexed SELECT MAX( lookup on the table to obtain the maximum
column value. Typically, this is achieved by making the column the first column of some table index.
ai_col)
While initializing a previously specified AUTO_INCREMENT column on a table, InnoDB sets an
exclusive lock on the end of the index associated with the AUTO_INCREMENT
column. While accessing the auto-increment counter, InnoDB uses a specific
AUTO-INC table lock mode where 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 the AUTO-INC table lock is held. See Section
5.4.4, "AUTO_INCREMENT Handling in InnoDB".
When you restart the MySQL server, InnoDB may reuse an
old value that was generated for an AUTO_INCREMENT column but never stored
(that is, a value that was generated during an old transaction that was rolled back).
When an AUTO_INCREMENT integer column runs out of
values, a subsequent INSERT operation returns a duplicate-key error. This
is general MySQL behavior, similar to how MyISAM works.
DELETE FROM
does not regenerate the table but instead deletes all rows, one by one. tbl_name
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, and DB_MIX_ID). The server
reports error 1005 and refers to error –1 in the error message. This restriction applies only to use of
the names in uppercase.
LOCK
TABLES acquires two locks on each table if innodb_table_locks=1
(the default). In addition to a table lock on the MySQL layer, it also acquires an InnoDB table lock. Versions of MySQL before 4.1.2 did not acquire InnoDB table locks; the old behavior can be selected by setting innodb_table_locks=0. If no InnoDB table
lock is acquired, LOCK
TABLES completes even if some records of the tables are being locked by other
transactions.
In MySQL 5.6, innodb_table_locks=0 has no effect for tables locked explicitly with
LOCK TABLES ...
WRITE. It does have an effect for tables locked for read or write by LOCK TABLES ... WRITE implicitly (for example, through triggers)
or by LOCK TABLES ...
READ.
All InnoDB locks held by a transaction are released
when the transaction is committed or aborted. Thus, it does not make much sense to invoke LOCK
TABLES on InnoDB tables in autocommit=1 mode because the acquired InnoDB table locks would be released immediately.
You cannot lock additional tables in the middle of a transaction because LOCK TABLES
performs an implicit COMMIT and UNLOCK TABLES.
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.