It sounds like it's either
- Index unbalancing over time
- Disk fragmentation
- Internal innodb datafile(s) fragmentation
You could try analyze table foo
which doesn't take locks, just a few index dives and takes a few seconds.
If this doesn't fix it, you can use
mysql> SET PROFILING=1;
mysql> INSERT INTO foo ($testdata);
mysql> show profile for QUERY 1;
and you should see where most of the time is spent.
Apparently innodb performs better when inserts are done in PK order, is this your case?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…