這是Uday。我用一個innodb小表對寫入性能有問題。Mysql:在我的本地機器上觀察到插入和更新都很慢
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.
如何獲得與innodb_flush屬性設置爲1相同的性能只.. ..?
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;
我試圖像OPTIMIZE TABLE不同的選項,增加了日誌緩衝區,檢查網絡延遲,但沒有一個人工作。我會非常感謝那些願意幫助我的人。
這裏是表的DESC和EXPLAIN。
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正在工作正常。問題僅在於UPDATE/INSERT。
問候, UDAY
沒有模式和索引列表,甚至猜測都很難。例如,非常多的索引可能是一個原因。 – 2012-03-30 14:10:03
將解釋更新wlists的輸出設置爲customer_id = 1000,其中id = 300;' – Cfreak 2012-03-30 14:10:42
Joachim&freck,我已經更新了所需的。 -Uday – Uday 2012-03-30 14:33:44