just one more sql optimalisation