At some point of the database upgrade from 3.2 to 3.4, Zabbix Server starts running queries like that for each event ID:
update alerts set p_eventid=53850802 where eventid=53850827
While there is only ~60K records in alerts table, update takes hours because it runs queries for all the 87 million event IDs one by one (99+% of which do not exist in alerts table at all).
Batching this update using some JOIN query would do much good there. If impossible, then preloading alerts table as well and updating only really affected alerts would be sane.