MySQL is probably already doing what you describe, as much as it can.
In the case of InnoDB (which should be your default storage engine with MySQL), inserts and updates and deletes change primary key or unique key indexes immediately. But they never rebuild the whole index, they add new values into (or take values out of) these indexes.
For non-unique indexes, InnoDB performs change buffering. That is, it queues the changes, which will be merged into the index later in the background. It will even consolidate changes so that the physical updates to the index are done more efficiently.
You don't have to do anything to enable this feature, because it's enabled by default. MySQL 5.1 does change buffering only for INSERT
. MySQL 5.5 and later additionally does change buffering for UPDATE
and DELETE
.
You can disable this feature if you want (for instance if you use SSD, avoiding random I/O is not so important, and you might want to ensure that queued changes don't accumulate). Normally, you should keep the feature enabled.