mining technical details – How Bitcoin client/miner fast verify balances?

Bitcoin client must fast find balances for some public keys. Especially miner must find balances for all incoming transactions. I see problems: public key with associated address can appear many times in 300 GB blocks data which can’t be whole in memory. Full Bitcoin client uses binary data files and LevelDB index(?). How can it do fast? Especially, miner spent most time to hashing, not veryfying transactions (?)