Changing order in order to improve mysql performance.