Reduces # of SQL queries in determining presences number.
Further SQL optimization.