I want to insert 20000 records from an entity structure into an entity and it takes about 2 minutes. Is there any way other than using SP to improve its performance? This is my code:
foreach (employee items in order) {t = new employee (); T. Text = item Text; DataContext.Employees.AddObject (t); } Datacontext Save Changes (); There is an opportunity for many improvements (if you are using DbContext then
code>):
set Do:
yourContext.configuration.AutoDetectChangesEnabled = false; YourContext.configuration.ValidateOnSaveEnabled = false; In the package of 100 codes, do SaveChanges ()
do ... or you can try with 1000 items and see changes in performance. Because during all this insertion, the context is the same and it is getting bigger, you can rebuild your reference object in every 1,000 inserts. var yourContext = new YourContext ();
I think this is a big advantage.
By making this improvement in my imported data process, it took it from 7 minutes to 6 seconds
Actual number ... your case can not be 100 or 1000. ..Try it and tweak it.
No comments:
Post a Comment