When uploading a large translation document, we commit in batches of 100 TextFlowTargets, but we fire a TextFlowTargetStateEvent for each TFT. The event handler for TextFlowTargetStateEvent (ie ActivityServiceImpl.logTextFlowStateUpdate) then generates a separate transaction for every one of these events, all of which are updating a single row of the database (the Activity entry for the document).
This leads to 101 transactions per batch, instead of one or two.
We should find a way to aggregate these activities. For instance, perhaps TranslationServiceImpl.translateAllInDoc should fire a single event per document which triggers a single transaction against the Activity table.