5. mysql> SHOW ENGINES *************************** 1. row *************************** Engine: MyISAM Support: DEFAULT Comment: Default engine as of MySQL 3.23 with great performance *************************** 2. row *************************** Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tables *************************** 3. row *************************** Engine: InnoDB Support: YES Comment: Supports transactions, row-level locking, and foreign keys *************************** 4. row *************************** Engine: BerkeleyDB Support: NO Comment: Supports transactions and page-level locking *************************** 5. row *************************** Engine: BLACKHOLE Support: YES Comment: /dev/null storage engine (anything you write to it disappears) You can set the default storage engine to be used during the current session by setting the storage_engine or table_type variable: SET storage_engine=MYISAM; SET table_type=BDB;
6. ISAM ISAM is a well-defined, time-tested method of managing data tables, designed with the idea that a database will be queried far more often than it will be updated. ISAM performs very fast read operations and is very easy on memory and storage resources. The two main downsides of ISAM are that it doesn't support transactions and isn't fault-tolerant: If your hard drive crashes, the data files will not be recoverable. MyISAM MyISAM is MySQL's extended ISAM format and default database engine. In addition to providing a MyISAM uses a table-locking mechanism to optimize multiple simultaneous reads and writes. MyISAM also has a few useful extensions such as the MyISAMChk utility to repair database files and the MyISAMPack utility for recovering wasted space. MyISAM, with its emphasis on speedy read operations, is probably the major reason MySQL is so popular for Web development, . As a result, most hosting and Internet Presence Provider (IPP) companies will allow the use of only the MyISAM format. MySQL DBEngines
7. MyISAM manages nontransactional tables. It provides high-speed storage and retrieval, as well as fulltext searching capabilities. MyISAM is supported in all MySQL configurations, and is the default storage engine unless you have configured MySQL to use a different one by default. Offers great performance for read heavy applications. Most web services and data warehousing applications use MyISAM heavily. MySQL DBEngines
8. Important notes about MyISAM tables: 1. Your tables will get corrupted eventually! Plan accordingly. 2. Turn on auto-repair by adding this flag to your my.cnf file: myisam-recover=backup,force 3. Super fast for read (select) operations. 4. Concurrent writes lock the entire table. Switch everything to offline processing where you can, to serialize writes without taking the database down. (Offline processing is golden and applies to all table types) MySQL DBEngines
9. CREATE TABLE tblMyISAM ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id), value_a TINYINT ) TYPE=MyISAM or ENGINE=MyISAM CREATE TABLE tblISAM ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id), value_a TINYINT ) TYPE=ISAM or ENGINE=MyISAM
10. Memory or HEAP: The MEMORY storage engine provides in-memory tables. HEAP allows for temporary tables that reside only in memory. Residing in memory makes HEAP faster than ISAM or MyISAM, but the data it manages is volatile and will be lost if it's not saved prior to shutdown. HEAP also doesn’t waste as much space when rows are deleted. HEAP tables are very useful in situations where you might use a nested SELECT statement to select and manipulate data. Just remember to destroy the table after you’re done with it. Note The MEMORY storage engine formerly was known as the HEAP engine. MySQL DBEngines
11. While this type of table offers super fast retrieval, it only works well for small temporary tables. If you try to load too much data into a Memory table, MySQL will start swapping information to disk and then you lose the benefits of an all-memory storage MySQL DBEngines
12. The InnoDB and BDB storage engines provide transaction-safe tables. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints. Although much slower than the ISAM and MyISAM engines, InnoDB and BDB include the transactional and foreign-key support missing from the former two choices. As such, if your design requires either or both of these features, you’re actually compelled to use one of these two choices MySQL DBEngines
13. Important notes about InnoDB tables: 1. ACID transactions support. Row-level locking (compared to table level locking with MyISAM) means faster concurrent writes. 2. Doing a "SELECT Count(*) FROM table" without specifying any indexes is very slow on InnoDB and requires a full table scan. (With MyIsam this operation doesn't cost anything because MyIsam stores an internal record counter with each table). If you need to "SELECT COUNT(*)" often on InnoDB tables, create MySQL insert/delete triggers that will increment/decrement a counter whenever records are added or deleted from the table. MySQL DBEngines
14. 3. Backup: MySQLDump backup is too slow with InnoDB. 4. InnoDB has built-in recovery that works 99% of the times automatically. Never try to move .frm or .ibd files around as a way of "helping" the database to recover. 5. InnoDB is less forgiving than MyIsam when it comes to queries on non indexes. InnoDB is going to "School" you into ensuring every single query and update statement runs on an index. Issue no index queries and you'll pay dearly in execution time. 6. Never ever change my.cnf INnoDB log file size while the database is running. You'll corrupt the log sequence number beyond repair.
15. The ARCHIVE storage engine is used for storing large amounts of data without indexes with a very small footprint. The CSV storage engine stores data in text files using comma-separated values format. The BLACKHOLE storage engine accepts but does not store data and retrievals always return an empty set. The FEDERATED storage engine was added in MySQL 5.0.3. This engine stores data in a remote database. Currently, it works with MySQL only, using the MySQL C Client API. In future releases, we intend to enable it to connect to other data sources using other drivers or client connection methods. MySQL DBEngines
16. Examples: Below are some examples of using the best storage engine for different tasks: Web stats logging - Flat file for the logging with an offline processing demon processing and writing all stats into InnoDB tables. Financial Transactions - InnoDB Session data - MyISAM Localized calculations - HEAP Dictionary - MyISAM