Fix performance issue of scheduled task