InnoDB (MySQL 5.5 Default Engine) Slower on INSERT

This section provides a tutorial example showing that InnoDB, the MySQL 5.5 storage engine, is about 1,000 times slower than MyISAM storage engine.

To find out why MySQL 5.5 is so slow to insert records comparing to MySQL 5.0 I searched the Internet and found the answer. By default, MySQL 5.5 creates table using the InnoDB storage engine, while MySQL 5.0 uses the MyISAM engine. So the performance difference is mainly due to the difference of the storage engine.

Let's take a look at the current storage engine of the table, drop the table and create the table again with the MyISAM engine:

C:\herong>\local\mysql\bin\mysql -u root

mysql> use HerongDB;
Database changed

mysql> show table status;
| Name    | Engine | Version | Row_format |...
| profile | InnoDB |      10 | Compact    |...

mysql> drop table profile;

mysql> create table profile (
    -> ID INTEGER PRIMARY KEY AUTO_INCREMENT,
    -> FirstName VARCHAR(20) NOT NULL,
    -> LastName VARCHAR(20),
    -> Point REAL DEFAULT 0.0,
    -> BirthDate DATE DEFAULT '1988-12-31',
    -> ModTime TIMESTAMP DEFAULT '2006-12-31 23:59:59.999')
    -> ENGINE=MyISAM;

mysql> show table status;
| Name    | Engine | Version | Row_format |...
| profile | MyISAM |      10 | Dynamic    |...

Now re-run MySqlPerformancePreparedStatement.java on a Windows 7 system with a 2.5GHz processor, running JDK 1.8, MySQL 5.5 and MySQL Connnector/J 5.1.36:

C:\herong>\Progra~1\java\jdk1.8.0_45\bin\java 
   -cp .;\local\lib\mysql-connector-java-5.1.36-bin.jar 
   MySqlPerformancePreparedStatement

PreparedStatement insert 10000 rows with 879 milliseconds

The total execution time dropped from 945810 milliseconds to 879 milliseconds. So MyISAM is about 1,000 times faster than InnoDB for simple inserting record operations.

Here is summary of what we have learned so far:

Operationg System: Windows 7
CPU speed: 2.5GHz
JVM version: 1.8.0_45
MySQL: 5.5
JDBC driver: MySQL Connnector/J 5.1.36
Operation: PreparedStatement for INSERT

Storage engine      # of inserts   Time in ms.   Comparison
MyISAM              10000          879           100%
InnoDB              10000          945810        107601%

As a comparison, here is the result of the same program on an older MySQL version:

Operationg System: Windows XP
CPU speed: 997MHz
JVM version: 1.6
MySQL: 5.0
JDBC driver: MySQL Connnector/J 5.0.7
Operation: PreparedStatement for INSERT

Storage engine      # of inserts   Time in ms.   Comparison
MyISAM              10000          1281          100%

Last update: 2015.

Table of Contents

 About This Book

 JDBC (Java Database Connectivity) Introduction

 JDK (Java SE) Installation

 Installing and Running Java DB - Derby

 Derby (Java DB) JDBC Driver

 Derby (Java DB) JDBC DataSource Objects

 Java DB (Derby) - DML Statements

 Java DB (Derby) - ResultSet Objects of Queries

 Java DB (Derby) - PreparedStatement

 MySQL Installation on Windows

 MySQL JDBC Driver (MySQL Connector/J)

MySQL - PreparedStatement

 PreparedStatement Overview

 PreparedStatement with Parameters

 PreparedStatement in Batch Mode

 Performance of Inserting Rows with a PreparedStatement

InnoDB (MySQL 5.5 Default Engine) Slower on INSERT

 Performance of Inserting Rows with a Regular Statement

 Performance of Inserting Rows with a ResultSet

 MySQL - Reference Implementation of JdbcRowSet

 MySQL - JBDC CallableStatement

 MySQL CLOB (Character Large Object) - TEXT

 MySQL BLOB (Binary Large Object) - BLOB

 Oracle Express Edition Installation on Windows

 Oracle JDBC Drivers

 Oracle - Reference Implementation of JdbcRowSet

 Oracle - PreparedStatement

 Oracle - JBDC CallableStatement

 Oracle CLOB (Character Large Object) - TEXT

 Oracle BLOB (Binary Large Object) - BLOB

 Microsoft SQL Server 2005 Express Edition

 Microsoft JDBC Driver for SQL Server - sqljdbc42.jar

 Microsoft JDBC Driver - Query Statements and Result Sets

 Microsoft JDBC Driver - DatabaseMetaData Object

 Microsoft JDBC Driver - DDL Statements

 Microsoft JDBC Driver - DML Statements

 SQL Server - PreparedStatement

 SQL Server CLOB (Character Large Object) - TEXT

 SQL Server BLOB (Binary Large Object) - BLOB

 JDBC-ODBC Bridge Driver - sun.jdbc.odbc.JdbcOdbcDriver

 JDBC-ODBC Bridge Driver - Flat Text Files

 JDBC-ODBC Bridge Driver - MS Access

 JDBC-ODBC Bridge Driver - MS SQL Server

 Summary of JDBC Drivers and Database Servers

 Additional Tutorial Notes to Be Added

 Outdated Tutorials

 References

 PDF Printing Version