none
Really poor performance... RRS feed

  • Question

  • I have tables that are associated as follows:

    Table0:

    Table1: Has a foreign key to Table0

    Table2: Has a foreign key to Table0

     

    In the code generated by LINQ to SQL, the class for Table 0 contains an EntitySet<Table1> and an EntitySet<Table2>.   If I allow these to be delay-loaded, there are some noticeable lags during actions in the UI.  I'd like to avoid this by getting these EntitySets loaded when the datacontext is initially opened.  I used DataLoadOptions.LoadWith to have Table1 entities loaded with Table0 entities.  This performed quite well.  However, when I add another LoadWith to get the Table2 entities loaded with Table0 entities, it takes quite a long time when I load the Table0 entities.  So long, in fact, that I have yet to let it go to completion.   My hunch is that the queries are becoming too complicated when multiple LoadWith's are included for Table0.  To summarize... if I include a LoadWith for either Table1 or Table2, it works.  Adding both LoadWith calls causes unacceptable performance during initialization.

    Any ideas on how I might work around this would be appreciated.  

    Tuesday, August 3, 2010 2:38 PM

Answers

  • There are plenty of reasons not to do it that way.

    Indeed, my point is that the approach to tell the compiler to load both table1 and table2 is pretty much the same (your database design becomes eyecandy) and probably the reason why is taking that long.

    You are better of improving other parts of your app if you want no lag at all such as trimming your queries, using sp or/and T-sql.

    Regards

    Tuesday, August 3, 2010 4:09 PM

All replies

  • If you are going to do it like that, then there is no difference between just putting all your data on a single table because you are effectibly telling the compiler to load everything related.

    Regards

    Tuesday, August 3, 2010 3:10 PM
  • There are plenty of reasons not to do it that way.  
    Tuesday, August 3, 2010 4:02 PM
  • There are plenty of reasons not to do it that way.

    Indeed, my point is that the approach to tell the compiler to load both table1 and table2 is pretty much the same (your database design becomes eyecandy) and probably the reason why is taking that long.

    You are better of improving other parts of your app if you want no lag at all such as trimming your queries, using sp or/and T-sql.

    Regards

    Tuesday, August 3, 2010 4:09 PM