Eficiency on slow networks (lazy loading)

Posts   
 
    
Posts: 14
Joined: 13-Apr-2009
# Posted on: 10-Dec-2009 13:57:19   

Hi

I have searched the forums but have not found an answer at least 80% satisfactory.

LLBLGen Pro 2.6 (Self servicing), VS2008, C#...

I'am develloping an app already in production but is time to move the app to a scenario with a substancially slower network (especially for upload, 8 times more slower than download). Getting a collection of 350 entities LLBLGen executes a query in each table of reference data referenced per master entity retrieved (350 X more upload...), any chance to change this behaviour?

Lazy loading: i have concluded that for the upper case lazy loading, LLBLGen is retrieving desnecessary child entities (for that case), what is the parameter to specify lazy loading in method getMulti?

I Know the quality of my english...

Regards

Desbaratizador

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 10-Dec-2009 21:15:30   

To prevent the numerous individual queries when using lazy loading, the solution is to use PreFetch paths. This means that if you are getting a collection of (say) customers, each with their related orders, one query will be run to fetch all of the customers, and then one more will be used to fetch all of the orders for all of those customers. LLBLGen then merges the two resultset to produce the object graph.

Matt

Posts: 14
Joined: 13-Apr-2009
# Posted on: 11-Dec-2009 14:05:06   

I don“t know the concept of prefetch paths (i will study).

Same for reference data? If my customers have a nacionality field, it is possible to fetch also the Nacionality table one time?

And how to use prefetch paths (one query only for customers) and avoid query orders (sometimes only the master entity is only i want).

Desbaratizador

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 11-Dec-2009 14:29:12   

And how to use prefetch paths (one query only for customers) and avoid query orders (sometimes only the master entity is only i want).

If only you need to fetch the master entity, you should avoid accessing the child entities or collections from your application. i.e. this is something you can control from the code using the DAL(generated code).

The rule is: LazyLoading lets you fetch related entities automatically when you access them for the first time (and if they are not fetched already by a prefetchPath).

If this is not an acceptable behaviour for you, then I'd suggest to use the Adapter model rather than SelfServicing.

Posts: 14
Joined: 13-Apr-2009
# Posted on: 11-Dec-2009 14:36:54   

Only to clarify: - How it is possible to turn on/off lazy loading (parameters of getMulti) ?

Or a low level configuration?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 11-Dec-2009 15:03:36   

It's possible, but involves modifying the templates, which is perhaps not something to be playing with if you are new to LLBLGen.

The following threads address the issue.

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=2428&HighLight=1 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5753&HighLight=1

Matt

Posts: 14
Joined: 13-Apr-2009
# Posted on: 14-Dec-2009 19:28:48   

Although i 'am using prefetch paths for getting the collection of master entities, at some point LLBLGen Pro is querying the entities one by one: "SELECT TOP 1 ... FROM 'Master'", at 'grid.DataSource = col'.

Why?

Desbaratizador

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Dec-2009 03:00:21   

Please post the code where you are building the prefetchPath and explain the unexpected results.

David Elizondo | LLBLGen Support Team
Posts: 14
Joined: 13-Apr-2009
# Posted on: 15-Dec-2009 18:56:01   

Case closed...

One event of a grid invokes a getMulti with maxNumberOfItems = 1.

Desbaratizador

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 15-Dec-2009 21:38:47   

Thanks for updating.

Matt