I'm using ubuntu 12.04 LTS Processor : Pentium(R) Dual-Core CPU E5200 @ 2.50GHz × 2 OS Type : 64-bit Memory : 3.9 GiB Disk : 101.1 GB
I installed mysql and wanted to test insert performance. Here is my table structure
> create table mytable (text varchar(200)) engine=InnoDB;
+-------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+-------+
| text | varchar(2000) | YES | | NULL | |
+-------+---------------+------+-----+---------+-------+
I wrote a simple python script for testing Insert performance. i.e. How many inserts per second?
import _mysql
import time
con = _mysql.connect('localhost', 'root', 'root', 'mydb')
stop = time.time()+1
while time.time() < stop: # runs loop for 1 sec
con.query("INSERT into mytable VALUES('Test Data')")
I expected atleast 8-10k inserts. But I'm getting only 25 inserts.
I tried many optimization techniques given in various blogs
1. Tried to run the loop in 1 transaction.
2. Tried LOAD DATA INFILE 'new.txt' INTO TABLE mytable
I also set innodb_flush_log_at_trx_commit=2 in /etc/mysql/my.cnf
But none of them worked, getting only 25-30 inserts per second. What to do?