The difference between InnoDB and MyISAM


The difference between InnoDB and MyISAM in mysql database files
Innodb isolation level principle realizes
InnoDB master-standby replication 1.

Differences between InnoDB and MyISAM

1. MyISAM uses prefix compression technology to make indexes smaller , while InnoDB stores data in the original data format.
2. MyISAM indexes refer to the indexed rows by the physical , while InnoDB refers to the indexed rows based on the primary key. InnoDB does not need to update this "pointer" in the secondary index when moving, but using the primary key value as a pointer will make the secondary index take up more space.
3. MyISAM primary key index is B+Tree + unique non-null index . InnoDB primary key index is B+Tree + clustered index . Clustered index: The primary key is the index, and the leaf nodes contain the index and row data.
4. MyISAM locks the entire table ( table lock ), and InnoDB has row -level locks .
5. MyISAM itself only caches the index ( depending on the operating system to cache data , set the appropriate key cache, and leave enough memory for the operating system). InnoDB caches indexes and data (cache pool should be maximized).


Second, the index



    index is implemented in the storage engine layer rather than the server layer.
    clustered index : Not a separate index type, but a data storage method . Leaf pages contain index and row data. InnoDB aggregates data by primary key . If there is no primary key, InnoDB will choose a unique non-null index instead.

   Self-incrementing primary key ID sequence insertion performance is high, UUID primary key ID random I/O, frequent page split operations, data fragmentation. UUID is suitable for distributed databases and prevents auto-incrementing primary key conflicts.

Three, Innodb index structure
    1. Innodb index is a B-tree data structure.
    2. The Innodb index includes at least two segments, one for storing non-leaf node data and the other for storing leaf node data.
    3. The segment is composed of pages. The page size of each page is 16K by default. Other values ​​can be set through the innodb_page_size configuration parameter: 8k, 32k. By default, 1/16 of the page_size is reserved for future index row changes and modifications. The default configuration can be changed through the parameter innodb_fill_factor.
    4. The maximum row length of mysql is limited to 65535 , variable columns are not included in 65536 , and charset is related, such as utf8, the maximum length is 65535/3. The maximum row data size including variable columns (VARCHAR, VARBINARY, BLOB, TEXT) is 4G .
    5. The maximum row length of mysql should not exceed 1/2 of the page size , if a row of data does not exceed 1/2 page size, then this row of data is all stored on the same page. If it exceeds 1/2 page size, then variable columns (VARCHAR, VARBINARY, BLOB, TEXT) are stored in other external pages.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326111182&siteId=291194637