Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Slow EntityCollection.AddRange when using Context
 

Pages: 1
Bugs & Issues
Slow EntityCollection.AddRange when using Context
Page:1/1 

  Print all messages in this thread  
Poster Message
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 20-Mar-2016 21:21:04.  
I have latest LLBL, using adapter.

I found issue with EC.AddRange performance when EC is in Context

Scenario:
Say I want "refresh" ecManagedCollection
First I fetch entities into ecTempCollection and if some conditions are ok, then I want to put those entities to ecManagedCollection.

Very simple code looks like:

Code:
Dim myContext As New Context()
myContext.Add(ecManagedCollection)

Using adapter As New DataAccessAdapter()
    Dim ecTempCollection As New HelperClasses.EntityCollection(Of myEntityType)()
    adapter.FetchEntityCollection(ecTempCollection)

    ecManagedCollection.Clear()
    ecManagedCollection.AddRange(ecTempCollection)
End Using


If I fetch 10k records then command "ecManagedCollection.AddRange(ecTempCollection)" takes about 10-20seconds.

If I disable using context by comment out "myContext.Add(ecManagedCollection)" then fetching 10k records takes 0,5sec

If I use Context but I do not use ecTempCollection, I fetch directly to ecTempCollection, then it takes also 0,5 sec.

Means looks like using Context brings huge overhead into .AddRange.
Could you look at that?

I tried in different apps, different databases and different DAL code.
Same result, when EC is in Context then EC.AddRange is 10-20x slower that direct fetch or when using ecTemp+not using context.
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8088 posts
# Posted on: 21-Mar-2016 05:53:05.  
What is your LLBLGen version and runtime library version? ( http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717 )

What are the special checks that you do before adding entities from ecTempCollection to ecManagedCollection?


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 21-Mar-2016 09:56:24.  
LLBLGEN v4.2.16.311

Even in posted simple code without any additional logic the .AddRange is very slow
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37644 posts
# Posted on: 21-Mar-2016 15:31:30.  
This is likely due to events being fired, as adding an entity to a collection means the FK fields are synced too.

It's also the case that adding an entity will do a linear search for checking whether the same entity already exists. If you know the data is new (like in your case) set the DoNotPerformAddIfPresent property of the collection to false. This way the collection won't make a linear search each time an entity is added, which should speed things up.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.