patternsqlMinor
Mysql innoDB write operations are extremely slow
Viewed 0 times
operationsareinnodbextremelywriteslowmysql
Problem
I'm having serious performance problems with MySQL and the InnoDB engine. Even the simplest table makes writing operations (creating the table, inserting, updating and deleting) horribly slow, as you can see in the following snippet.
I have been looking at htop and the long waiting times are not because of abnormal CPU load. It's almost zero, and memory usage is also normal. If I create the same table using the MyISAM engine, then it works normally. My my.cnf file contains this (if I remember right I haven't changed anything from the default Debian configuration):
```
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
bind-address = 127.0.0.1
key_buffer = 40M
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
myisam-recover = BACKUP
max_connections = 100
table_cache = 64
thread_concurrency = 10
query_cache_limit = 1M
query_cache_size = 40M
log_slow_querie
mysql> CREATE TABLE `test` (`id` int(11) not null auto_increment,
-> PRIMARY KEY(`id`)) ENGINE=InnoDB;
Query OK, 0 rows affected (4.61 sec)
mysql> insert into test values ();
Query OK, 1 row affected (1.92 sec)
mysql> insert into test values ();
Query OK, 1 row affected (0.88 sec)
mysql> insert into test values ();
Query OK, 1 row affected (1.10 sec)
mysql> insert into test values ();
Query OK, 1 row affected (6.27 sec)
mysql> select * from test;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
+----+
4 rows in set (0.00 sec)
mysql> delete from test where id = 2;
Query OK, 1 row affected (0.28 sec)
mysql> delete from test where id = 3;
Query OK, 1 row affected (6.37 sec)I have been looking at htop and the long waiting times are not because of abnormal CPU load. It's almost zero, and memory usage is also normal. If I create the same table using the MyISAM engine, then it works normally. My my.cnf file contains this (if I remember right I haven't changed anything from the default Debian configuration):
```
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
bind-address = 127.0.0.1
key_buffer = 40M
max_allowed_packet = 16M
thread_stack = 128K
thread_cache_size = 8
myisam-recover = BACKUP
max_connections = 100
table_cache = 64
thread_concurrency = 10
query_cache_limit = 1M
query_cache_size = 40M
log_slow_querie
Solution
-
-
-
"Batch"
-
-
-
Still, the times (1s-6s) are grossly unreasonable. Even with everything set "wrong", 0.1s for a simple
Is this running in a "cloud"? Is something else going on?
innodb_flush_log_at_trx_commit = 2 for better speed (=1 for better safety)-
sync_binlog = 0 if you are not using the binlog.-
"Batch"
INSERTs — many rows in a single INSERT statement. (If you have lots, do 100 at a time.) LOAD DATA is also excellent for loading.-
innodb_buffer_pool_size = 70% of available RAM.-
auto_commit = 1, or use BEGIN ... COMMIT-
thread_stack = 256K I'm surprised it did not crash with your small value.Still, the times (1s-6s) are grossly unreasonable. Even with everything set "wrong", 0.1s for a simple
INSERT should be expected.Is this running in a "cloud"? Is something else going on?
Context
StackExchange Database Administrators Q#28104, answer score: 7
Revisions (0)
No revisions yet.