Only perform query reset and restore if needed.