views:

167

answers:

3

Does anyone know if there's a speed difference between a query with Entity Framework instead of SQL normal application? With entity Framework, we must manualy handle joins between tables and to my eyes, it seems like a fairly complex query.

Given a customer with many joins on State/Province, Orders, Gender, Comments, favorites products, ... etc. Suppose, 15 relations. It takes about 3 or 4 seconds to execute a simple "View" page which shows the information. For me, and my boss ( hehe ), it surely takes TOO much time.

If I write this in ordinary SQL, will it work faster?

+1  A: 

It would be best to use a profiler to determine where the bottleneck is. Keep in mind that in most cases fast enough = good enough. If 3 or 4 seconds is acceptable given the context in which the query is made then leave well enough alone.

Premature optimization is a waist of energy. - Food for thought.

codeelegance
I've tried this when debuggin on local. This taking less than 2 seconds. 1,2 secondes exactly to execute all my page process. The maximum i saw its 2,3 seconde for an update. Maybe its because of our web host cuz it seems to take 1 or 2 secondes more than localy.Sorry for my english, i know its not quite good.
Simon
+1  A: 

The number of joins you have in your queries suggests that they could be written to be much simpler. Queries with this many joins will run slowly whether you run them through the Entity Framework or use a SQL Data Reader.

Robert Harvey
A: 

We've found out that its preaty much faster when you loadProperty manually instead of doing it with an .Include when creating the query with LINQ on the context. Now, all our request takes less than 2 secondes even for a big entity with 17 relationships.

We also found out that for small entity, there's not a significient difference between .Include and LoadProperty, but when you come with entity with more than 10 - 12 relationship, it comes a little bit tricky.

Tanks for answer and ... heum, sorry for my english! I'm giving my best!

Simon