Now that custom dimensions is included in core I think we could improve the performance of the tracker and have less updates.
Currently, as soon as a custom dimension is configured for a site, we execute an additional query like
UPDATE log_visit SET last_idlink_va = '2222' WHERE idsite = '1' AND idvisit = '3333'.
We could maybe get rid of this extra update query for existing visits if we knew we first insert the action and then update the visit. Then we could in the regular visit update also update the
last_idlink_va. Not sure if there would be maybe a reason this wouldn't work and whether we have to update the visit before the action.
For new visits this would not work because we need to have the idvisit to insert the action. This likely makes this quite tricky to implement...
I was thinking we could maybe also get rid of the extra action update but this is not the case because it actually updates the action before this action.
Note: the query is only executed when there are action custom dimensions defined so its impact is limited.