MySQL storage engine, MyISAM, InnoDB

  A, MySQL MyISAM and InnoDB storage engine how to choose

  MySQL has multiple storage engines, each storage engine has its own advantages and disadvantages, you can choose the best use: MyISAM, InnoDB, MERGE, MEMORY (HEAP), BDB (BerkeleyDB), EXAMPLE, FEDERATED, ARCHIVE, CSV, BLACKHOLE.

  While in the MySQL storage engine MyISAM and InnoDB not just two, but two is common.

  Roughly difference between the two storage engine features:

  1) InnoDB support transactions, MyISAM does not support, and this is very important. A transaction is an advanced treatment methods, such as in a series of additions and deletions as long as the mistakes which can also rollback restore, and MyISAM not it.

  2) MyISAM for query-based applications as well as insert, InnoDB for frequent modifications, and involve high security applications.

  3) InnoDB support foreign keys, MyISAM does not support.

  4) From MySQL5.5.5, InnoDB is the default engine.

  5) InnoDB FULLTEXT index type is not supported. But you can use InnoDB sphinx plug-in supports full-text indexing.

  6) number of rows in the table is not saved in the InnoDB, such as select count (*) when from table, InnoDB need to scan the entire table again to calculate how many rows, but MyISAM simply read a good number of rows to save. Note that, when the count (*) statement contains a condition where MyISAM also need to scan the entire table.

  7) For the field of self-growth, InnoDB must contain only the index of the field, but in the MyISAM table can index and other fields to establish a joint together.

  8) Empty the entire table, InnoDB is to delete the line by line, the efficiency is very slow. MyISAM will rebuild the table.

  9) InnoDB row lock support (in some cases the whole table is locked as update table set a = 1 where user like '% lee%'.

  Second, on the MyISAM and InnoDB choose to use:

  MYISAM and INNODB are two Mysql database storage engines provided. The pros and cons of both can be described as different. INNODB will support some of the advanced features of a relational database, such as transaction capabilities and row-level locking, MYISAM not supported. MYISAM better performance, less storage space. So, choose what kind of storage engine, depending on the specific application:

  1) If your application must use the transaction, there is no doubt you have to choose INNODB engine. But pay attention, INNODB of row-level locking is conditional. When conditions where there is no primary key, the lock will still be a full table. For example, DELETE FROM mytable such a delete statement.

  2) If your application requires a high query performance, it is necessary to use a MYISAM. MYISAM index and data are separated, and the index which is compressed, can make better use of memory. So its query performance significantly better than INNODB. Index after the compression can save some disk space. MYISAM have full-text indexing, which can greatly optimize efficiency LIKE query.

  Some say MYISAM only be used for small applications, it is merely a prejudice.

  If a large amount of data, which is required to resolve by upgrading infrastructure, such as sub-sub-table database, rather than simply relying on a storage engine.

  Now we are generally chosen innodb, mainly myisam full table lock, read and write serial problem, complicated by the efficiency of the lock table, inefficient myisam for read and write intensive applications do not normally go chosen. Big Data learning Qiuqiu attached Qun * 606 * + [859] then attached 705

  Third, on the Mysql database default storage engine:

  MySQL MyISAM and InnoDB are two storage engines.

  If it is installed by default, it should be InnoDB, you can find the default-storage-engine = INNODB my.cnf file;

  Of course, you can specify the storage engine at the time of construction of the table.

  Corresponding information can be seen through the show create table xx.

  Fourth, in comparison Mysql InnoDB and MyISAM in

  1)MyISAM:

  Each MyISAM storage into three files on disk. The name of the first file name of the table to begin the extension indicates the file type.

  frm file stores the table;

  Data MYD (MYData) of the file storage table;

  Index MYI (MYIndex) file storage table.

  MyISAM tables can be compressed, and they support full-text search. It does not support transactions, but does not support foreign keys. If things rollback will result in incomplete rollback, not atomic. Table updata lock for performing concurrent relatively small. If you do a lot of SELECT, MyISAM is a better choice.

  MyISAM index and data are separated, and the index is compressed, memory usage corresponds to improve a lot. More can load index and is Innodb index and data are closely tied, do not use compression which will result in Innodb bulky than MyISAM is not small.

  MyISAM index is cached in memory, not data. The InnoDB data is cached in memory, relatively speaking, the greater the server's memory, the greater the InnoDB play advantage.

  Pros: relatively fast query data for a large number of select, full-text indexing.

  Disadvantages: does not support transactions do not support foreign keys, a small amount of concurrency is not suitable for mass update

  2)InnoDB:

  This type of transaction is safe. It has the same type of characteristics BDB, they also support foreign keys. InnoDB table fast. BDB has also richer than features, so if you need a transaction-safe storage engine, it is recommended to use it. Table row lock during update, a relatively large amount of concurrency. If you perform a large number of data INSERT or UPDATE, for performance reasons, you should use InnoDB tables.

  Advantages: support services, support for foreign keys, concurrency is large, suitable for mass update.

  Disadvantages: relatively fast query data, not suitable for a large number of select.

  Support for InnoDB table types of things, affect the speed of the main reasons is the default setting AUTOCOMMIT is turned on, and the program does not explicitly call BEGIN begin a transaction, each lead automatically insert a Commit, seriously affecting the speed. You can call begin before executing sql, sql form a number of things (even if autocommit can also be opened), will greatly improve performance.

  The basic difference is:

  MyISAM does not support the type of advanced processing transaction processing, while InnoDB type support.

  MyISAM table type to emphasize that performance, which performs several times faster than InnoDB type, but does not provide transaction support, and InnoDB provides transaction support advanced database features have external keys.


Reproduced in: https: //juejin.im/post/5d09d5b96fb9a07f091ba717

Guess you like

Origin blog.csdn.net/weixin_33893473/article/details/93174471