Optimize update_statistics running time