TechEd Europe 2010 Day 4
I made it to the sessions this day, but memories of the Dutch country drinks kept coming back. Anyway, the most interesting part was a deep dive into the database performance of using the Entity Framework 4 as data access layer and LINQ. When you use these do you by definition make code that is less efficient than carefully coded stored procedures? The surprising answer is: No. You have to abide by the following rules though:
- Use the Entity Framework 4 and not earlier incarnations, because everything before EF4 sucks.
- Never use literals in your conditions, because this will result in less efficient (non-RPC) SQL queries
- Do not return whole entities unnecessarily, because in returning all internal entities the query suddenly bloats with LEFT OUTER JOINS
Bottom line is that the queries that EF4 queries easily outperform badly written stored procedures. Exceptions are queries affecting multiple records and stored procedures that process data in a way that is better expressed in SQL. Happy coding with EF4!
by Wim The
| Trackback Url
| Link to this post