Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Issue #124

Open
brianv509 opened this issue Sep 29, 2016 · 1 comment
Open

Performance Issue #124

brianv509 opened this issue Sep 29, 2016 · 1 comment

Comments

@brianv509
Copy link

I have a scenario where I need to soft delete ~2500 rows at a time. Im looking to see if there is a better way to perform this task to get some quicker response times. Maybe some bulk insert with the audit logging?

Right now the breakdown is as follows:
-Initial select statement into the context is 2mins (very slow)
-Soft Delete update statement is 11secs (slow)
-The Audit log inserts is 41secs (very slow)
I’ve also try to just do a SQL query as a base line and it takes 1sec to perform all tasks.

Here is the code im executing:


//Pull list of everything that needs to be updated
var locationFixtures = Context.LocationFixtures.Where(lf => lf.FixtureId == fixtureId);

foreach (var entity in locationFixtures)
{
    Context.LocationFixtures.Attach(entity);
    entity.IsDeleted = true;
    entity.DeletedDateTime = DateTimeOffset.UtcNow;
}

Context.SaveChanges();

@aboyaniv
Copy link

aboyaniv commented Aug 7, 2017

  1. you don't need to do Attach (entity) you are pooing the entities from the database. (remove the line)
  2. set GlobalTrackingConfig.DisconnectedContext = false; see https://github.com/bilal-fazlani/tracker-enabled-dbcontext/wiki/0.-Techniques

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants