MySQL engine [turn]

Database Engine introduces
MySQL MySQL database engine depends on how the installation is being compiled. To add a new engine, it must be recompiled MYSQL. By default, MYSQL supports three engines: ISAM, MYISAM and HEAP. And the other two types INNODB BERKLEY (BDB), also often be used. If skilled, you can also use MySQL + API to own one engine. Here are some database engines:

ISAM : ISAM is a well-defined and time-tested data management table, which at the time of design to take into account the number of times the number of database queries is much larger than the update. Therefore, ISAM speed read operation is performed quickly, and do not take up a lot of memory and storage resources. ISAM two main shortcomings is that it does not support transactions, can not fault tolerant: If your hard drive crashes, then data files can not be recovered. If you are the ISAM used in mission-critical applications where it must always back up all your data in real time, through its replication features, MYSQL can support such a backup application.

MyISAM : MySQL's ISAM MyISAM is the default extended format and database engine. In addition to providing ISAM not in the index and field management of a large number of functions, MyISAM tables also use the locking mechanism to optimize multiple concurrent read and write operations, the cost is that you often need to run the OPTIMIZE TABLE command to restore the update the mechanism of wasted space. MyISAMCHK tool MyISAM some useful extensions, such as to repair the database file and MyISAMPACK tool to restore a waste of space. MYISAM stressed the fast read operation, which is probably why MySQL WEB development has been the main reason for such a favor: in a WEB development in large amounts of data are the actions you performed a read operation. Therefore, most web hosting providers and platform providers INTERNET allows only MYISAM format. An important flaw MyISAM format that they can not recover data after table corruption.

HEAP : HEAP to allow only resides in memory temporary tables inside. Let reside in memory HEAP faster than ISAM and MYISAM, but the data it manages is unstable, and if not to save before the shutdown, then all data will be lost. When the data rows are deleted, HEAP will not waste a lot of space. HEAP table is very useful when you need to use the SELECT expressions to select and manipulate data. Remember, you drop a table used up form.

InnoDB : InnoDB database engine is MySQL to create a direct product of technology flexibility, this technology is MYSQL + API. When using MYSQL, every challenge you face almost from ISAM and MyISAM database engine does not support transaction processing (transaction process) does not support foreign keys. Although slower than many of ISAM and MyISAM engine, but includes support for InnoDB transaction processing and foreign keys, these two are the first two engines do not have. As mentioned earlier, if your design requires one or both of these features, then you will be forced to use one of the two engines in the rear.


MyISAM and InnoDB difference between
  InnoDB and MyISAM are many people in the use of MySQL most commonly used type of two tables, two table types have advantages and disadvantages, depending on the specific application. The basic difference is: MyISAM type of advanced processing transactions, which do not support, and support for InnoDB type. 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 following are some of the details and specific differences in implementation:
1.InnoDB FULLTEXT index type is not supported.
Specific number of rows of 2.InnoDB not save the table, that is, the implementation of select count (*) fromtable when, InnoDB again to scan the entire table to calculate how many rows, but MyISAM simply read out the number of lines that is good save can. Note that, when the count (*) statement contains a condition where the operation two kinds of tables is the same.
3. For AUTO_INCREMENT type of field, InnoDB must contain only the index of the field, but in the MyISAM table, you can index and other fields to establish a joint together.
When 4.DELETE FROM table, InnoDB will not re-establish the table, but delete the line by line.
5.LOAD TABLE FROMMASTER InnoDB operation does not work, the solution is first put into InnoDB tables MyISAM table, and then import the data into InnoDB tables, but for additional InnoDB characteristics (e.g., foreign key) used in Table Not applicable.
Further, InnoDB table row lock is not absolute, and can not determine if MySQL range to be scanned, InnoDB tables will also lock the whole table, a SQL statement in the implementation example updatetable set num = 1 where name like
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.
The reason is as follows:
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 do some selectcount this merge table (*) operation, it is ideal for large projects total about hundreds of millions of rows of a certain type (such as log , 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 starting, I will first 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.
Generally, MyISAM for:
(1) do count a lot of computing;
(2) insert infrequent queries very frequently;
(3) there is no transaction.
InnoDB for:
(1) high reliability requirements, or require a transaction;
(2) table updates and queries are quite frequent, and the opportunity to watch the locked relatively large designated to create a data engine.


Let all the flexibility possible switch is provided to the ANSI SQL MySQL extension --TYPE parameters. MySQL allows you to specify the form this layer database engine, so they sometimes refer to the table formats. The following sample code shows how to create tables were used MyISAM, ISAM and HEAP engine. Note that the code to create each table is the same, except for the last of the TYPE parameter, this parameter is used to specify the data engine.
The following is the contents of references:

CREATE TABLE tblMyISAM (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=MyISAM
CREATE TABLE tblISAM (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=ISAM
CREATE TABLE tblHeap (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=Heap

You can also use the ALTER TABLE command, the original form from one engine to another engine. The following code shows how to use ALTER TABLE engine to InnoDB MyISAM table to move: The

following is the contents of references:

ALTER TABLE tblMyISAM CHANGE TYPE=InnoDB

MySQL with three steps to achieve this purpose. First, a copy of this table is created. Then, any input data changes are queued, while the copy is moved to another engine. Finally, any queued data changes are sent to the new form, the form and the original is deleted.

ALTER TABLE shortcuts

If you just want to update tables from ISAM to MyISAM, you can use MySQL_convert_table_format command, without writing ALTER TABLE expression.

You can use the SHOW TABLE command (which is another MySQL extension to the ANSI standard) to determine which engines in the management of a particular form. SHOW TABLE returns a result set with multiple columns of data, you can use this result set to query to get all types of information: the name of the database engine in the Type field. The following example code illustrates SHOW TABLE Usage:
copy the code code is as follows:

SHOW TABLE STATUS FROM tblInnoDB

TABLE you can use SHOW CREATE [TableName] SHOW TABLE to retrieve information can be retrieved.
Under normal circumstances, MySQL offers a variety of default storage engine, you can view the following:
(1) watch your MySQL storage engines now offer what: MySQL> Show Engines;
(2) to see your current default MySQL storage engine : MySQL> show the Variables like '% storage_engine%';
(3) you want to see a table with what engine (the results are displayed in the parameters of the engine behind the table to indicate the current storage engine used): mysql> show create table table;
and finally, if you want to use MySQL is not compiled into the engine has not been activated, it is of no use, MySQL will not prompt this. And it only will give you a default format (MyISAM) table. In addition to using the default table format, there is a way to give MySQL error, but for now, if you are not sure whether a particular database engine is available, you have to use SHOW TABLE to check the table format.
More choices mean better performance
engines for a given table need to be recompiled and tracking, taking into account the additional complexity of this, why do you still want to use non-default database engine it? The answer is simple: To adjust the database to meet your requirements.
To be sure, MyISAM is indeed fast, but if you need transaction processing logic design, you can freely use to support transaction processing engine. Furthermore, since MySQL can allow you to form this layer database engine application, so you can only form required to carry out transaction performance optimization, while the form of the transaction does not require more light to the MyISAM engine. For MySQL, the flexibility is the key.

Other aspects
1.MySQL official InnoDB is explained this way: InnoDB provides MySQL with a with a commit, rollback, and crash recovery capabilities of transaction-safe (ACID compliant) storage engine. InnoDB row-level locking SELECT statement and also provides an Oracle-style consistent non-locking read, these features increase multi-user deployment and performance. There is no need to expand locked in InnoDB, because InnoDB BOC-level locking for very small space. InnoDB also supports FOREIGN KEY mandatory. In the SQL query, you can freely type InnoDB table types with other MySQL tables mixed up, even in the same query can also be mixed.
2.InnoDB maximum performance is designed to handle the huge amount of data, its CPU efficiency may be any other disk-based relational database engine can not match.
3.InnoDB storage engine is fully integrated with MySQL server, InnoDB storage engine to cache data and indexes in main memory and maintains its own buffer pool. InnoDB stores its tables & indexes in a table space, table space can contain several files (or raw disk partitions). This is different from MyISAM table, such MyISAM tables each table is present in a separate file. InnoDB tables can be any size, even when the file size is limited to the operating system 2GB.
4.InnoDB default is included in MySQL binary distribution. Windows Essentials installer makes InnoDB the default table of MySQL on Windows.
5.InnoDB is used to generate at numerous large database sites requiring high performance. The famous Internet news site Slashdot.org runs on InnoDB. Mytrix, Inc. store more than 1TB of data in InnoDB, there are other sites processed on average 800 times per second InnoDB insert / update.

Guess you like

Origin www.cnblogs.com/ericz2j/p/11110674.html