This question already has an answer here:
I support a system called "dynamics ax" and sometimes my optimizer picks a good plan, drops it and then picks a bad plan (where the same code is been ran). users who usually wait for 10 seconds start waiting for 30 sec. sometimes i update statistics and it goes back to it's normal time and then in a couple of minutes it starts running slow. does anyone has idea on how i can resolve this??