Click here to Skip to main content
15,896,453 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Quick Website Builder Pin
John Krause17-Feb-17 8:05
John Krause17-Feb-17 8:05 
GeneralRe: Quick Website Builder Pin
Eddy Vluggen17-Feb-17 8:08
professionalEddy Vluggen17-Feb-17 8:08 
GeneralRe: Quick Website Builder Pin
John Krause17-Feb-17 8:18
John Krause17-Feb-17 8:18 
GeneralRe: Quick Website Builder Pin
Eddy Vluggen17-Feb-17 8:19
professionalEddy Vluggen17-Feb-17 8:19 
GeneralRe: Quick Website Builder Pin
Jeremy Falcon17-Feb-17 7:54
professionalJeremy Falcon17-Feb-17 7:54 
GeneralRe: Quick Website Builder Pin
Kent Sharkey17-Feb-17 8:50
staffKent Sharkey17-Feb-17 8:50 
GeneralRe: Quick Website Builder Pin
Jeremy Falcon17-Feb-17 9:06
professionalJeremy Falcon17-Feb-17 9:06 
GeneralEntity Framework optimization fun Pin
Dave Kreskowiak17-Feb-17 5:55
mveDave Kreskowiak17-Feb-17 5:55 
So, I'm trying to squeeze a bit more performance out of a LINQ query executed by EF. It's used pretty frequently and returns just a page of data at a time, complete with filtering and sorting support for various columns. This thing grabs data from 11 tables, basically a status summary row from a bunch of different operations on a single record.

I go look in the SQL Profiler at the query EF generates and find it's hitting the database about 25-ish times, once for the main page of data (pagable grid) and once for each record in the page to fill in a couple of pieces of data for those records that were accidentally not Included in the original query. OK, not problem, easy fix to remove those extra trips to the database. Quick'n'easy.

I also notice the main page query is a bit ... large. 544 lines of SQL with 19 LEFT OUTER JOINS! Wow. I knew EF generated some crappy SQL but this is ridiculous. The other 24-ish hits are small EF house keeping queries and filling in missing pieces of data from the original page query. Not big deal.

So, I put in a couple of missing Includes in the query code and test it out. Great! Down to five trips to the database instead of 25 and the grid page response is about four times faster than it was. Awsome!

Out of curiosity, I go look at the new SQL for the grid page query. It's now 977 lines of SQL with 35 LEFT OUTER JOINS!! OMG | :OMG: WOW!

Oh, it runs in less than 100 milliseconds.
A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: Entity Framework optimization fun Pin
Marc Clifton17-Feb-17 6:00
mvaMarc Clifton17-Feb-17 6:00 
GeneralRe: Entity Framework optimization fun Pin
Sander Rossel17-Feb-17 6:30
professionalSander Rossel17-Feb-17 6:30 
GeneralRe: Entity Framework optimization fun Pin
lopatir17-Feb-17 7:02
lopatir17-Feb-17 7:02 
GeneralRe: Entity Framework optimization fun Pin
Sander Rossel17-Feb-17 11:09
professionalSander Rossel17-Feb-17 11:09 
GeneralRe: Entity Framework optimization fun Pin
Eddy Vluggen17-Feb-17 7:45
professionalEddy Vluggen17-Feb-17 7:45 
GeneralRe: Entity Framework optimization fun Pin
Sander Rossel17-Feb-17 11:13
professionalSander Rossel17-Feb-17 11:13 
GeneralRe: Entity Framework optimization fun Pin
Slacker00717-Feb-17 7:05
professionalSlacker00717-Feb-17 7:05 
GeneralRe: Entity Framework optimization fun Pin
R. Giskard Reventlov17-Feb-17 7:12
R. Giskard Reventlov17-Feb-17 7:12 
GeneralRe: Entity Framework optimization fun Pin
Dave Kreskowiak17-Feb-17 7:20
mveDave Kreskowiak17-Feb-17 7:20 
GeneralRe: Entity Framework optimization fun Pin
Slacker00717-Feb-17 7:23
professionalSlacker00717-Feb-17 7:23 
QuestionVideo hardware/software question Pin
David Crow17-Feb-17 5:40
David Crow17-Feb-17 5:40 
AnswerRe: Video hardware/software question Pin
OriginalGriff17-Feb-17 5:52
mveOriginalGriff17-Feb-17 5:52 
GeneralRe: Video hardware/software question Pin
David Crow17-Feb-17 6:05
David Crow17-Feb-17 6:05 
JokeRe: Video hardware/software question Pin
Marc Clifton17-Feb-17 5:56
mvaMarc Clifton17-Feb-17 5:56 
GeneralRe: Video hardware/software question Pin
OriginalGriff17-Feb-17 6:21
mveOriginalGriff17-Feb-17 6:21 
GeneralRe: Video hardware/software question Pin
Cornelius Henning17-Feb-17 7:13
professionalCornelius Henning17-Feb-17 7:13 
GeneralRe: Video hardware/software question Pin
Jörgen Andersson17-Feb-17 23:33
professionalJörgen Andersson17-Feb-17 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.