Optimize conditions for RecentAttend* with stored procedures