Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF RIA Services query slow
    text
    copied!<p>I have a WCF RIA Services domain service backed by Entity Framework. The entity model is quite complex. Generally, performance is OK for most operations.</p> <p><em>However</em> my Silverlight client includes a master/details view. The master view is a list of entities. Clicking between the entities to select them fires the <em>IQueryable GetEntity()</em> method on the server, and this is taking on average 5 seconds - an unacceptable amount of time.</p> <p>I use Fiddler to look at the call over the wire, and I can see that all my time is being spent on the server:</p> <pre><code>ServerGotRequest: 15:59:44.545 ServerBeginResponse:15:59:48.836 ServerDoneResponse: 15:59:48.836 ClientBeginResponse:15:59:48.836 ClientDoneResponse: 15:59:48.836 Overall Elapsed: 00:00:04.2940000 </code></pre> <p>The data returned, as it appears on the wire, is also quite small. In this example, around 6kb.</p> <p>OK - so my problem is server side. The query into EF is fairly simple, with one caveat: we have ~25 .Include statements to bring in related entities. The .Includes select entities up to 4 levels deeps (e.g. .Include("1.2.3.4")). </p> <p>So my next thought is that that the DB is slow. No so - I run SQL Profiler and see the (admittedly dreadful) SQL gets executed in, on average, 0.15 seconds. The data returned is not that bad - 3 rows of around 275 columns.</p> <p>So:</p> <ul> <li>My bottleneck is on the server</li> <li>I select multiple, related entities through a straight EF query</li> <li>The SQL generated is ugly, but fast enough</li> </ul> <p>So why am I slow? How can I debug this?</p> <p>If I set a breakpoint at the end of my <em>IQueryable GetEntity()</em> method, it seems that after exiting that method it takes up to 3 seconds before the actual query appears in SQL Profiler. WTF?</p> <p>Note that I have pre-generated my Entity Framework views, and I have tried using a compiled query to rule out EF 'warm up' times. No difference.</p> <p>I appreciate any help with this issue. Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload