Improve performances by removing many SQL queries