This is a migrated thread and some comments may be shown as answers.

CopyFrom

2 Answers 79 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sven
Top achievements
Rank 1
Sven asked on 15 Jul 2009, 02:20 PM

We have two tables A and B with a many-to-many relationship. This is realized via a simple link table containing the IDs of each table.
Only table A contains some 500 rows - the link table and table B are completely empty. If we now try to access the data with
 
var result = from x in scope.Extent<A>() select x;
List<A> resultlist = result.ToList();

everything works fine. But trying to fill an ObjectContainer afterwards by
 
ObjectContainer oc = new ObjectContainer();
oc.CopyFrom(scope, "MyNamedList", result, null);

the CopyFrom takes an extremely long time to complete (approx. 3 minutes for 500-1000 rows in A).
Looking at the log output it shows that for each row in A a JOINed query is performed on B.
In our case the DB is accessed by an internet connection - running against a local SQLExpress DB the effect might not be that noticeable.

2 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 17 Jul 2009, 11:28 AM
Hello Sven,

I think there are two issues here:
(a) The original query should fetch everything that is needed later in the CopyFrom in an efficient manner.
      In your case you should have a FetchField attribute set on A's B collection field, and add the fetch  
      group to the FetchPlan of the scope before doing the query.
      In addition to that please set the ParallelFetch property of the result to true. This allows us to just issue
      two queries; Optimal!
(b) The fetched data can be GC'ed. In order to avoid that you need to specify
<pmCacheRefType>STRONG</pmCacheRefType>  
      in the backend configuration section of your app.config file manually. This changes the way OpenAccess references data that was read from the server but is not referenced from the user app - like the query result content.

Kind regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Sven
Top achievements
Rank 1
answered on 17 Jul 2009, 12:30 PM
Thanks for supporting our evaluation. Actually this did the trick.
Tags
General Discussions
Asked by
Sven
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Sven
Top achievements
Rank 1
Share this question
or