# How to tune insert and update statements?

**URL:** <https://forums.percona.com/t/how-to-tune-insert-and-update-statements/662>\
**Category:** Other MySQL® Questions\
**Created:** [March 6, 2008, 5:12am UTC](https://forums.percona.com/t/how-to-tune-insert-and-update-statements/662 "2008-03-06T05:12:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![susheel](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@susheel](https://forums.percona.com/u/susheel)\
**Post date:** [March 6, 2008, 5:12am UTC](https://forums.percona.com/t/how-to-tune-insert-and-update-statements/662/1 "2008-03-06T05:12:51Z")

</div>

Hi all,

I am using mysql 4 on solaris 8.  
Can anyone plese give me suggestions how to improve the performance of insert and update statements without making any changes in code.

Regards  
Susheel

---

<div class="post-metadata">

**Author:** ![sterin](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sterin](https://forums.percona.com/u/sterin)\
**Post date:** [March 17, 2008, 5:27pm UTC](https://forums.percona.com/t/how-to-tune-insert-and-update-statements/662/2 "2008-03-17T17:27:36Z")

</div>

To speed up insert’s you should have as few indexes as possible.  
But to speed up update’s and selects you need indexes.  
So you have a Catch-22 on your hand.  
The problem is that it’s not so easy to optimize a database so that you can give any general advice that will always work out of the box. It all depends on your data and what query pattern your application has.

But here are two tips for different storage engines:  
If you are using InnoDB tables you can turn off flushing of the transactin log by setting:  
innodb\_flush\_log\_at\_trx\_commit=2  
in my.cnf.

And if you are using MyISAM then you can get some advantages by having a table optimized. But that only works if you can optimize the table after deletes. Which isn’t always possible since the table has to be locked during this optimization.
