I can see how SELECT
and UPDATE
statements get slower as a table grows and grows, but what about INSERT
?
views:
86answers:
5
+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
2010-07-06 09:07:50
good point about the indexes
Haroldo
2010-07-06 09:09:10
+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
2010-07-06 09:15:31