More efficient CSV Export

Transition CSV export to a fancy raw SQL solution. Should be significantly faster than the ActiveRecord implementation.