Just the slightest bit of cacheing when writing SQL/CSV should make it run 100x faster