How does the network check for double spending so efficiently?
Nodes have a UTXO set which is a database containing all UTXOs. Once they receive a transaction, they check whether the inputs exist in the UTXO set or not and they reject the transaction, if it doesn't exist.
Once nodes receive a new block, they update the UTXO set.