The primer linked above is certainly a good way to start.
I've never been one to pay for bottled water, so I took the entirety of my water company's reported history, plotted all the data, and averaged it month to month to account for seasonal changes. Given that all the numbers line up in terms of ion balance, and that my actual mash pH is always within 0.1 of what Bru'N Water predicts (as measured by calibrated pH meter), the system works fine for me. And, of course, treat my water with campden tablets for the chlorine and chloramine.
As far as the chemistry behind it, I would check out Bru'N Water. In addition to the best spreadsheet for water calculations and mash pH prediction I've ever used, his water knowledge page is absolutely fantastic.
Paying attention to water didn't help my efficiency. But it made my beers taste better all around.