I find it interesting that if I make a purchase as a credit transaction -- that it takes a couple of days to clear, but yet, the hold can be communicated immediately. If the networks in place can already immediately verify funds and place a hold -- why not just clear the transaction immediately ?
Transactions are processed in batches because there's multiple parties involved. There are two main steps:
Authorization - that is what triggers the hold. The merchant through his own merchant account provider contacts the issuer of the card to ask whether the issuer would accept the transaction had it been submitted at that time. If the issuer would - the issuer gives an authorization code to the merchant, which is typically valid for 7-30 days (depending on the type of the expected transaction). As long as the code is valid, the issuer would put a hold on the account in that amount to cover for the expected transaction. This is more of a "smoke test" for the merchant that the card is not stolen/canceled, that it is not over the limit, and that it is likely to be OK to accept it.
Transaction - that's the longer process and is usually not done online but rather in batch, typically nightly. The only thing happening right away (even that not always) would be the merchant recording the transaction and the authorization code.
Once the transaction is processed by the merchant, it will then be submitted to the merchant account processor. This is done in batches, usually daily. The processor then credits the merchant account (balancing all the refunds, chargebacks, ect).
The processor then aggregates all the transactions and balances out its own cards (if the processor is also an issuer). The transactions using cards issued by others are then submitted to the network (Visa/Mastercard/etc).
The network, in another batch, then balances out all the transactions for the processor (balancing the amounts the processor is owed due to others' cards being used in its merchants with what the processor owes for its cards being used with other processors).
The network then distributes the transactions to the issuers to charge the accounts, which is also done in a batch - yet another. The issuers then accept that information and post the transactions to the respective accounts. When posting, the issuers match the authorization code recorded with the transaction to the authorization code attached to the hold, and remove the hold if there's a match. Sometimes the merchant get authorization but don't attach it to the transaction, and then you may end up with the transaction posted by the hold not removed automatically.
As you can see, this is a multi-step process with multiple parties involved. Since at this stage money is actually changing hands - it cannot be done online per transaction, since the volume would be enormous. It is done in batches, with only the aggregate balances moving around.
This behavior depends heavily on the merchant in question. When you charge to a credit card, the information for that charge goes immediately to the credit card company, but the charge won't show as fully processed until the merchant confirms that transaction. These captures are traditionally queued up and processed in batches, for historical reasons.
This separation between the information initially sent, 'authorization,' and the money actually changing hands, 'capture,' is the same thing that allows for things like tipping at a restaurant, where the actual amount varies from the initial authorization. So there's some positive sides to the wait.
Lastly, there is a single step version of a credit card transaction, but it's not widely supported.