Summarizing six major differences between INNODB and MyISAM table types in MySQL database

Source: Internet
Author: User
Tags table definition mysql database

The difference in composition:

MyISAM

Each myisam is stored on disk as three files. The first file begins with the name of the table, and the extension indicates the file type.

. frm file storage table definition.

The data file has an extension of. MyD (MYData).

The name of the index file extension is. Myi (Myindex).

InnoDB

A disk-based resource is a InnoDB tablespace data file and its log files, and the size of the InnoDB table is limited to the size of the operating system file, typically 2GB

Second, the transaction processing aspect:

MyISAM

Tables of the MyISAM type emphasize performance, which is performed more than the InnoDB type, but does not provide transactional support

InnoDB

InnoDB provides transaction support transactions, external key and other advanced database functions

Three, SELECT Update,insert,delete operation

MyISAM

If performing a lot of Select,myisam is a better choice

InnoDB

1. If your data performs a large number of inserts or updates, for performance reasons, you should use the InnoDB table

2.DELETE from table, InnoDB does not re-establish the table, but deletes one row at a time.

3.LOAD table from Master does not work for InnoDB, the solution is to first change the InnoDB table to MyISAM table, import the data and then change to InnoDB table, but for the use of additional InnoDB features (such as foreign key) of the table does not apply

Iv. operation of the Auto_increment

MyISAM

Internal processing of one auto_incremen column per table.

MyISAM automatically updates this column for insert and update operations. This makes the Auto_increment column faster (at least 10%). The value at the top of the sequence cannot be used again after it has been deleted. (When the Auto_increment column is defined as the last column of a multiple-column index, you can have a situation where the value deleted from the top of the sequence is reused).

Auto_increment value can be reset by ALTER TABLE or MYISAMCH

For fields of type auto_increment, InnoDB must contain an index with only that field, but in MyISAM tables, you can establish a federated index with other fields

Better and faster auto_increment processing

InnoDB

If you specify a auto_increment column for a table, the InnoDB table handle in the data dictionary contains a counter called the automatic growth counter, which is used to assign a new value to the column.

The automatic growth counter is stored only in main memory, not on disk

For the implementation of the calculator algorithm, please refer to the

Auto_increment how to work in InnoDB

Five, the specific number of rows of the table

MyISAM

Select COUNT (*) from Table,myisam as long as you simply read out the number of saved rows, note that when the COUNT (*) statement contains a where condition, the operations of both tables are the same

InnoDB

The exact number of rows for the table is not saved in the InnoDB, that is, when the select count (*) from table is executed, InnoDB scans the entire table to calculate how many rows

Six, lock

MyISAM

Table lock

InnoDB

Provides row locks (locking on row level), providing no lock reads consistent with Oracle type (non-locking read in

Selects), in addition, row locks on innodb tables are not absolute, and if MySQL cannot determine the range to scan when executing an SQL statement, the InnoDB table also locks the entire table, such as Update table set num=1 where name like "% aaa% "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.