Tomorrow is a significant optimization between the server and database in terms of computing electrum address status (ordered hash of all address history). I've implemented midstate hash caching maintained in each subscription at the server protocol object, with an address table surrogate key for the head of the last iteration applied to the midstate. The hash preimage requires an ordering of all txs creating and spending a given address. There are addresses with 5 million spends, possibly as much as 10 million history entries. Without this caching, just subscribing to an address requires the full query to run for every new block and even every new unconfirmed tx. This is because the notification for any new touch on the address requires the FULL SET of touches to be hashed in order. The ordering is such that a new event can cause a change in the middle of the hash preimage. So even midstate caching gets complex. Yes, this is a crazy design.
(edited)