Minimizing the wait time for nextTimeToQuery timeouts