How to choose MySQL storage engine MyISAM and InnoDB



How to choose MySQL storage engine MyISAM and InnoDB
MySQL has a variety of storage engines, each with its own advantages and disadvantages, you can choose to use: MyISAM, InnoDB, MERGE, MEMORY (HEAP), BDB (BerkeleyDB), EXAMPLE, FEDERATED, ARCHIVE, CSV, BLACKHOLE.
Although the storage engines in MySQL are not only MyISAM and InnoDB, but two are commonly used.
The general difference between the two storage engines is:
1) InnoDB supports transactions, but MyISAM does not, which is very important. Transaction is an advanced processing method. For example, in some column additions, deletions, and changes, as long as an error occurs, it can be rolled back and restored, but MyISAM cannot.
2) MyISAM is suitable for query and insert-based applications, InnoDB is suitable for frequent modification and applications involving high security
3) InnoDB supports foreign keys, MyISAM does not support
4) Since MySQL 5.5.5, InnoDB is the default engine
5) InnoDB Index
of FULLTEXT type is not supported Just count. Note that MyISAM also needs to scan the entire table when the count(*) statement contains the where condition.
7) For self-growing fields, InnoDB must contain an index of only this field, but it can be combined with other fields in the MyISAM table. Index
8) When emptying the entire table, InnoDB deletes line by line, which is very slow. MyISAM will rebuild the table
9) InnoDB supports row locks (in some cases, the entire table is locked, such as update table set a=1 where user like '%lee%'.

Regarding the choice between MyISAM and InnoDB:
MYISAM and INNODB are two storage engines provided by the Mysql database. The advantages and disadvantages of the two can be described as different. INNODB will support some advanced functions of relational databases, such as transaction functions and row-level locks, but MYISAM does not support. MYISAM has better performance and occupies less storage space. So, what kind of storage to choose Engine, depending on the specific application:
1) If your application must use transactions, there is no doubt that you should choose the INNODB engine. Note, however, that row-level locks in INNODB are conditional. When the where condition does not use the primary key, the entire table will still be locked. For example, delete statements such as DELETE FROM mytable.
2) If your application requires high query performance, you should use MYISAM. MYISAM indexes and data are separate, and their indexes are compressed for better memory utilization. So its query performance is significantly better than INNODB. Compressed indexes can also save some disk space. MYISAM has the function of full-text indexing, which can greatly optimize the efficiency of LIKE queries.

Some people say that MYISAM can only be used for small applications, in fact, this is just a bias.
If the amount of data is relatively large, this needs to be solved by upgrading the architecture, such as sub-table and sub-library, rather than simply relying on the storage engine.

Innodb is generally used now, mainly for myisam's full table lock, serial read and write problems, concurrency efficiency lock table, low efficiency Myisam is generally not used for read and write-intensive applications.

About the default storage engine of Mysql database:
MyISAM and InnoDB are two storage engines of MySQL.
If it is installed by default, it should be InnoDB. You can find default-storage-engine=INNODB in the my.cnf file; of
course, you can specify the corresponding storage engine when creating a table.
Corresponding information can be seen by show create table xx.

Comparison of InnoDB and MyISAM in Mysql
1) MyISAM:
Each MyISAM is stored as three files on disk. The name of the first file begins with the name of the table, and the extension indicates the file type. .frm files store table definitions. Data files have the extension .MYD (MYData).
MyISAM tables can be compressed, and they support full-text search. Transactions are not supported, and foreign keys are not supported. If the transaction is rolled back, it will cause an incomplete rollback, which is not atomic. Table locks are performed during updata, and the amount of concurrency is relatively small. MyISAM is a better choice if doing a lot of SELECTs.
The index and data of MyISAM are separated, and the index is compressed, and the memory usage is correspondingly improved a lot. More indexes can be loaded, and Innodb is tightly bound with indexes and data. Without compression, Innodb will be larger than MyISAM, and
MyISAM caches indexes in memory, not data. InnoDB caches data in memory. Relatively speaking, the larger the server memory, the greater the advantage of InnoDB.

Advantages: query data is relatively fast, suitable for a large number of selects, and can be full-text indexed.
Disadvantages: does not support transactions, does not support foreign keys, small concurrency, not suitable for a large number of updates

2) InnoDB: (parameter description: Mysql storage engine Innodb important parameter description)
This type is transaction-safe. .It has the same features as BDB types, they also support foreign keys. InnoDB tables are fast. It has richer features than BDB, so if you need a transaction-safe storage engine, it is recommended to use it. The table is row-locked during update, and the concurrency is relatively large. If your data performs a lot of INSERTs or UPDATEs, you should use InnoDB tables for performance reasons.
Advantages: support transactions, support foreign keys, large concurrency, suitable for a large number
of
updates , and the program did not explicitly call BEGIN to start the transaction, resulting in an automatic Commit for each inserted item, which seriously affected the speed. You can call begin before executing sql, and multiple sqls form one thing (even if autocommit is turned on), which will greatly improve performance.

The basic difference is: The
MyISAM type does not support advanced processing such as transaction processing, while the InnoDB type does.
The MyISAM type of table emphasizes performance. It performs several times faster than the InnoDB type, but does not provide transaction support, while InnoDB provides transaction support and advanced database functions such as foreign keys.
****************When you find that your talent can't support your ambition, please calm down and study***************

Guess you like

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