Working from http://help.dataobjects.net/##DataObjects.Net%20v4.5/html/bda59613-172c-427f-86fc-046ccd7e4253.htm I put together some code to try and solve an optimization problem. E.g.

Dim parentsLinq As IEnumerable(Of Parent) =
    From p As Parent In Xtensive.Orm.Session.Demand().Query.All(Of Parent)()
    Select p
    Take 10

parentsLinq = parentsLinq.Prefetch(Function(p As Parent) p.Children)
Dim parentsList As List(Of Parent) = parentsLinq.ToList()

Profiling this with the Red Gate ANTS performance profiler shows that this results in 2 SQL database calls. The first is for SELECT TOP 10 Parents, which is fine. The second is 10 separate queries for Children WHERE parentID=@p1_0 through parentID=@p1_10. Is there any way to make DataObjects use a single query (e.g. using JOIN) to prefetch the children? The database is running in Legacy_Validate mode.

asked Dec 11 '12 at 15:58

GigMastersTech's gravatar image

GigMastersTech
27111115

Hello GigMastersTech could you add the version of DataObjects.Net you're using?

(Dec 12 '12 at 01:37) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

We are using DataObjects.NET version 4.6.0.

(Dec 12 '12 at 11:45) GigMastersTech GigMastersTech's gravatar image

One Answer:

DataObjects.Net never uses joins for prefetch. It groups the entities to fetch and uses single query with IN operator. Prefetching of EntitySets currently does not have such grouping optimization thus this is expected behaviour.

answered Dec 13 '12 at 03:43

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Thanks for the explanation. :)

(Dec 13 '12 at 08:49) GigMastersTech GigMastersTech's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA