Do not keep the full statistics table in memory, write lines to file instead

1 job for optimize-servers in 3 minutes and 7 seconds (queued for 5 seconds)