tags:

views:

86

answers:

5

I can see how SELECT and UPDATE statements get slower as a table grows and grows, but what about INSERT ?

+5  A: 

INSERT gets slower too, especially if you have a lot of indexes which have to be updated as well.

There is a difference between the different storage engines though: MyISAM is faster for a lot of SELECT, InnoDB is faster for a lot of INSERT/UPDATE because it uses row locking instead of table locking and the way it handles indexes.

Konerak
good point about the indexes
Haroldo
+2  A: 

INSERT gets slower too, because it has to sort out the indexes.

xil3
+3  A: 

you can look on this article :

speed insert

Haim Evgi
+2  A: 

In general, yes - O(1) performance is rare anywhere and keeping the indexes current has a cost.

The question is, why does it matter, and what can you do about it in your specific case?

  • don't create indexes that are never used (e.g. I keep finding tables with an additional single-column index on the primary key)
  • don't keep useless data in the table (or, if you rarely use old data, consider moving them to an archive table/database)
  • iff you have a problem with insert speed and you don't care about autoincrement-IDs, INSERT DELAYED may help you
Piskvor
A: 

INSERT gets slower too

Saher