Performance in DataAccessAdapter

Posts   
 
    
alfonsoCid
User
Posts: 2
Joined: 09-Oct-2019
# Posted on: 09-Oct-2019 23:06:53   

I have a problem when the DataAccessAdapter is instantiated when it is run for the first time it takes a too long.

I read because the entities are loaded, whats is the best way to start loading or initialize the entities?

For example:



var entity = new ItemEntity(100);
using (var adapter = new DataAccessAdapter())  //1.5 - 2.3 seconds to load
adapter.FetchEntity(entity);


P.D. I'm using WCF self-host

Attachments
Filename File size Added on Approval
data_acces.PNG 146,307 09-Oct-2019 23:08.34 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Oct-2019 08:49:13   

Hi Alfonso,

How are you measuring those seconds? Are you using some kind of profiler?

What LLBLGen version and runtime version are you using? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717)

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 10-Oct-2019 10:03:19   

it likely triggers all static constructors and runs all initialization logic for the meta-data. I presume your model is very big? If you profile the first call you'll see it also reads (tries to) from the config file to obtain a connection string, which might be slow(er) as well. The first time a connection is created is also slow(er) than the others as a connection pool has to be started and the first live connection to the database is opened, which requires network layers to initialize (inside the ADO.NET provider).

Please profile the call and the methods it calls, the slowness you're seeing is in another class (but which one isn't possible to say with this info)

Frans Bouma | Lead developer LLBLGen Pro
alfonsoCid
User
Posts: 2
Joined: 09-Oct-2019
# Posted on: 10-Oct-2019 17:28:29   

daelmo wrote:

Hi Alfonso,

How are you measuring those seconds? Are you using some kind of profiler?

What LLBLGen version and runtime version are you using? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717)

I'm using NProfile and the result is the initialization of the DataAccesAdapter and some Entity at the first time is slow.

My LLBLGen version is 5.5.0.0 and my model has five fields.

And about this

Otis wrote:

Please profile the call and the methods it calls, the slowness you're seeing is in another class (but which one isn't possible to say with this info)

You mean the problem is not the ORM and is it my solution? Because I made a simple console program and is the same result.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 10-Oct-2019 19:06:20   

The data-access adapter class is very fast when instantiating but when you instantiate it for the first time, it will trigger e.g. the static constructor of the persistenceinfo class and other classes which build meta-data structures in memory. This is a one-time thing, but if your model is really large (e.g. 1000 entities or more) it can take some time (1-2seconds). That's why I asked you to profile the methods called as children of the constructor call (profilers usually show these methods as 'children' of the constructor call, also static constructors of other classes). For instance the query engine's static constructors are called at that moment as well, reading config data from the app/web.config file.

If this is a small model, then it's odd it takes that long, hence you should check what code is triggered by the constructor (i.e. which static constructors are slow). the constructor itself doesn't do much.

Frans Bouma | Lead developer LLBLGen Pro