I am calculating rankings for an entire 300 event season base off teams and games played. This means updating a ranking from oldest event to newest every night for ELO ratings.
We are using a UnitOfCommit
setup with Entity Framework 6
and after processing this large season it takes almost 5 minutes to update all the entities. I am doing bulk inserts which work great.
I have three type of entities that get updated. A list of entities called TeamOrganizationSeason
is a running total of all the events and needs to be saved at the end of the loop. The DivisionTeamRanking
and DivisionTeamRankingGame
can be saved at the end of each iteration in the loop instead of doing a bulk.
Is there a way to split up the commits to do the TeamOrganizationSeason
separate from the other two? Is there alway a better way to handle this?
// Start At First Event To Calculate Elo Running Values
foreach (var @event in events.Where(t => t.StartDate.HasValue).OrderBy(t => t.StartDate))
{
// Start Calculating Points and Ratings
// Could Save List<DivisionTeamRanking> and List<DivisionTeamRankingGame> here
}
// Could Save List<TeamOrganizationSeason> only here
UnitOfWork.Commit();