new sql query to address performance issues and missing students