only optimize db every 100 iterations