Wednesday, August 28, 2013

Entity framework - Retrieve related entity - Fetch Order - SQL Server 2008 R2

Hi,


You could perhaps use http://technet.microsoft.com/en-us/library/ms190233(v=sql.105).aspx to see which plan is used server side and which statements exactly are sent.


Technically speaking if you don't ask for a particular order, the server is free to return the resultset in whatever order he wants.


So perhaps does it do the first query using some descending index (do you have one ?) but updates some stats or whatever that makes it choose another plan the next time ?


If you are interested in finding out what happens you'll likely have first to find out if this is caused by EF or rather by SQL Server. Or just consider that this is possible and that the only way to guarantee a particular order is to explicitely ask for it...




Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


No comments:

Post a Comment