Modify mysql storage engine

What to query the database engine:

select table_name,`engine` from information_schema.tables where table_schema = 'database_name';

Engine lookup table (see MYISAM)
the SELECT CONCAT (table_name, '', Engine) information_schema.tables the WHERE table_schema the FROM = "BPM" the AND ENGINE = "MyISAM";  


生成修改sql(把MYISAM改成INNODB)
select CONCAT('alter table ',table_name,' engine=InnoDB;') FROM information_schema.tables WHERE table_schema="bpm" AND ENGINE="MyISAM"; 

Note: Mysql table built without InnoDB (large high read data) with MyISAM reasons

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. The main difference between the two types is Innodb support transaction processing and foreign keys, and row-level locking. The MyISAM does not support. Therefore, it is easy to MyISAM often been considered suitable only for use in small projects.

  I, as a user perspective using MySQL departure, Innodb and MyISAM are more like, but from my current operation and maintenance of the database platform to achieve demand: 99.9% of stability, convenience of scalability and high availability is the case, absolutely MyISAM It is my first choice.

  For the following reasons:

  1, first of all most of my current project is hosted on the platform reading and writing small projects rather than read performance MyISAM is a lot of strong Innodb.

  2, 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.

  3, from a platform perspective, often occur every month or two application developers do not accidentally update a table where the scope does not write, can not lead the table with normal, and this time MyISAM superiority manifested a casual correspondence table extracted from the compressed file copy day, just put under a directory database, and then dump into sql then turned back to the main database, and on the corresponding binlog complement. If Innodb, I am afraid that there can be such a fast speed, and I do not say let Innodb regularly with export xxx.sql backup mechanism, because the amount of data a minimum of a database instance on my platform basically tens of G size.

  4, application logic from my contact with it, select count (*) and order by most frequently, would be able to account for more than 60% of the total operation of the entire sql statement, and this is actually the operating Innodb will lock table many people think that Innodb is row-level locking, that it is only where the primary key is valid, non-primary key will lock the whole table.

  5, there is often a lot of applications departments need me to give them some regular data tables, MyISAM, then it is easy for them to send correspondence frm.MYD that table, MYI file, let them in the corresponding version of the database start on the line, and you need to export xxx.sql Innodb, because the light to others file, the affected data dictionary file, the other party can not be used.

  6, if the ratio insert MyISAM and write, then, Innodb yet reached MyISAM write performance, if it is for the update operation based on the index, although the MyISAM may be less Innodb, but so high concurrent write, from the library can chase on it is also a problem, not as by sub-library sub-table multi-instance architecture to solve.

  7, if it is, then use MyISAM, merge engine can greatly speed up application development department, as long as they merge on the table to do some select count (*) operation, is ideal for large projects total about hundreds of millions of rows of a certain type (such as logs, survey) business table.

  Of course Innodb not absolutely no use for Project Services such as stock market simulation project, I use active users more than 20 million times, is also very easy Innodb cope, so I personally also like to Innodb, but if the database platform application departure, I still preferred MyISAM.

  In addition, some people may say you MyISAM can not write too much anti, but I can be offset by the architecture, to say the use of my existing database platform capacity: the amount of data in a master-slave more than a few hundred T, more than one billion daily pv dynamic pages, there are several large projects through the data interface invoke not counted in the total number of pv, (including a major project since the beginning of memcached did not deploy, resulting in a single database handling 90 million queries per day). And my whole database server load average at around 0.5-1.
 

Published 29 original articles · won praise 5 · Views 7989

Guess you like

Origin blog.csdn.net/qq_25194685/article/details/103289701