It is possible that i am missing the point as I cant find any discussions on the following issue:
On both field_sql_storage_field_storage_write() & hook_field_storage_write() we have the following comment
// Delete and insert, rather than update, in case a value was added.
The code (for update operations) then deletes the field and the revision field and inserts the field and revision field
This to my possibly ignorant eyes looks like incredibly inefficient. I would expect to see the following logic:
1) Query existing value for the field
2) If doesn't exist: Insert field and field revision.
3) If exists and value is different: Update field and field revision.
This will have two improvements:
1) Write to the database only if value changed
2) Select + Update are much faster then Delete + Insert
Some of the benefits on database performance I can see are:
- Less database writes (insert/update)
- Less Fragmentation by updating instead of delete+insert
- Less UNDO and REDO info sql needs to handle
- Faster transactions and less chance of deadlocks
- Possibly less database index updates
I am no export on the Entity/Field API so if I have missed something significant my apologies, however if it is a valid point I would be happy to look into it further and possibly offer a patch