Correct optimized query5.

More info on how to improve this with hints incoming