Answered by:
Entity Framework Speed Consideration

Question
-
Hello,
I am building a rather large application with Entity Framework and it is working very well for the vast majority of the program. However, I am currently facing a page with a complex request that takes a very long time to finish. I pinpointed the delay to the database call, but when I make that same request directly in SQL Server Management Studio, it completes a lot faster (about five seconds compared to one minute).
I made some searches that indicate that the overhead for Entity Framework to build a complex request can result in performance loss. Some websites recommanded using a tool like dapper for complex queries.
I would like to have your opinion before changing anything.
Thank you very much for your assistance,
Francis
Thursday, February 23, 2012 9:40 PM
Answers
-
On 2/23/2012 4:40 PM, Francis Beaucage wrote:> Hello,>> I am building a rather large application with Entity Framework and it is> working very well for the vast majority of the program. However, I am> currently facing a page with a complex request that takes a very long> time to finish. I pinpointed the delay to the database call, but when I> make that same request directly in SQL Server Management Studio, it> completes a lot faster (about five seconds compared to one minute).Objects are being materialized when using Linq to query the database,which slows overall execution down.>> I made some searches that indicate that the overhead for Entity> Framework to build a complex request can result in performance loss.> Some websites recommanded using a tool like dapper for complex queries.>> I would like to have your opinion before changing anything.>> Thank you very much for your assistance,>In using compiled queries for a Web based solution where the compileLinq query is executed on the Web server, the compiled query stays instatic memory.There is also Entity SQL, which is like T-SQL that you can use forcomplex queries with a datareader. Using E-SQL may give you betterperformance.You can also T-SQL in the form of a sproc.In using E-SQL or T-SQL, you can still populate entites/objects on themodel.Friday, February 24, 2012 2:07 PM
All replies
-
On 2/23/2012 4:40 PM, Francis Beaucage wrote:> Hello,>> I am building a rather large application with Entity Framework and it is> working very well for the vast majority of the program. However, I am> currently facing a page with a complex request that takes a very long> time to finish. I pinpointed the delay to the database call, but when I> make that same request directly in SQL Server Management Studio, it> completes a lot faster (about five seconds compared to one minute).Objects are being materialized when using Linq to query the database,which slows overall execution down.>> I made some searches that indicate that the overhead for Entity> Framework to build a complex request can result in performance loss.> Some websites recommanded using a tool like dapper for complex queries.>> I would like to have your opinion before changing anything.>> Thank you very much for your assistance,>In using compiled queries for a Web based solution where the compileLinq query is executed on the Web server, the compiled query stays instatic memory.There is also Entity SQL, which is like T-SQL that you can use forcomplex queries with a datareader. Using E-SQL may give you betterperformance.You can also T-SQL in the form of a sproc.In using E-SQL or T-SQL, you can still populate entites/objects on themodel.Friday, February 24, 2012 2:07 PM
-
Hi,
I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?
If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, March 2, 2012 9:01 AM