change statement order to perform better on selecting by id