Reputation: 1490
This is Uday. I have a problem with the write performance with a small innodb table.
There is a table called "wlists" on my local machine(mysql 5.1.X).
It has 5 attributes and has less than 1000 rows.
By default, innodb_flush_log_at_trx_commit is set to 1 ;
Now the thing is that
every insert/update it is taking 0.04 seconds,
this is horrible because i can do just 54K inserts per hour.
When innodb_flush_log_at_trx_commit set to 2, its working fine.
What to do to get the same performance with innodb_flush attribute set to 1 only..?
Here are some other details that may help in addressing this:
load on the machine : Quite normal
innodb_log_file_size : 1MB
innodb_buffer_pool_size : 8MB
innodb_thread_concurrency : 8
Query : update wlists set customer_id = 1000 where id = 300;
I have tried different options like OPTIMIZE table, increasing the log buffer, checking the network latency but no one worked. I would be really thankfull to those who would help me here.
Here are the DESC and EXPLAIN of the table.
mysql> DESC wlists ;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| customer_id | int(11) | NO | MUL | NULL | |
| name | varchar(45) | YES | | NULL | |
| created | datetime | YES | | NULL | |
| modified | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)
mysql> explain select customer_id from wlists where id = 300 ;
+----+-------------+-----------+-------+---------------+---------+---------+-------+------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
----+-------------+-----------+-------+---------------+---------+---------+-------+------+
| 1 | SIMPLE | wishlists | const | PRIMARY | PRIMARY | 4 | const | 1 | |
+----+-------------+-----------+-------+---------------+---------+---------+-------+------+-------+
1 row in set (0.00 sec)
SELECT is working OK. Problem is only with the UPDATE/INSERT.
Regards, UDAY
Upvotes: 0
Views: 1302
Reputation: 8916
innodb_flush_log_at_trx_commit set to 1 will always cause performance slowdown on writes because InnoDB will wait for the operating system to return with disk success after each operation. Though, note that the operating system will sometimes lie based on its own caching.
But setting innodb_flush_log_at_trx_commit == 1 is also the only way to guarantee ACID and full data recovery (assuming the OS doesn't lie too much). So it's a tradeoff. The ideal way to deal with this is to have a battery-backed up storage system that has its own write caching. That way you get the advantage of write-caching without data recovery issues. Though of course you then have to make sure the battery backup is fully maintained, and you'll have write speed issues when the battery goes through regular maintenance cycles.
Upvotes: 1