Innodb insert optimization
The following query takes 1-10 secs in inserting a single row
INSERT INTO site_stats (stats_id, page_id, stats_time) VALUES(N, N, NOW());
stats_id and page_id are INT
MySQL slow log
Count : 80049 (26%)
Time : 184467445311844 s total, 2304431602 s avg, 1 s to 18446744073709 s max
95% of Time : 337702 s total, 4 s avg, 1 s to 78 s max
Lock Time : 4145198 s total, 51 s avg, 0 s to 8377 s max
Rows sent : 0 avg, 0 to 0 max
Rows examined : 0 avg, 0 to 0 max
Forgot to mention: I move records from this table to another every hour for pro开发者_运维技巧viding stats to users. Usually more than 7000 rows are inserted in one hour
Try some of the methods I showed this guy here:
CodeIgniter - ses_destroy() uses a LOT of CPU
Also, remove some of your less important indexes. Having multiple indexes can slow down your write statements.
精彩评论