Performance optimizations

See individual commit messages for more detail.

Perf target was Rails' ActiveRecord.

Current perf graph (via proftools.rb):

![foo](https://f.cloud.github.com/assets/28908/2208107/f414ec88-997b-11e3-8250-50d76366a5ed.gif)