principleMinor
Executing same request from C# VS SSMS give different execution time
Viewed 0 times
executingsamessmsrequestgivetimedifferentfromexecution
Problem
I have a request like this one
When i run this query in SSMS i get a executing time of 953ms, but when i run this query from a Linq Query in my C# i get a executing time of 1813ms.
The Linq Query use the ".Net SqlClient Data Provider" and is issued against EntityFramework (EDMX file). Is this can be an issue ?
Does anybody knows why i have a big difference between execution times of those requests that are the same but execute from different context against the same database ?
I verified all execution plans of both request and they use the same index to satisfy their respective query.
To see the execution plan of the C# request i use the SQL profiler to trap the Show Plan XML event and i compare it to the one of SSMS and both are the same.
SELECT
[EstimateId],
[CreationUserId],
[EstimateStatusValueId],
[LanguageId],
[LocationId],
[EstimatorUserId],
[FilterUnitSystemTypeId],
[EstimateNumber],
[RevisionNumber],
[CreationDate],
[ModificationDate],
[ProjectDescription],
[IsBsdq],
[ClosingDate],
[ClosingTime],
[ClosingUpdatedOn],
[DeadLineDate],
[IsReceived],
[Inclusion],
[Exclusion],
[Misc],
[Note],
[WorkDeadLines],
[Comments],
[Validity],
[PlansLocation],
[PlansReceivedFrom],
[Price]
FROM [Estimate].[Estimates]
ORDER BY [ClosingDate] ASC, [ClosingTime] ASCWhen i run this query in SSMS i get a executing time of 953ms, but when i run this query from a Linq Query in my C# i get a executing time of 1813ms.
The Linq Query use the ".Net SqlClient Data Provider" and is issued against EntityFramework (EDMX file). Is this can be an issue ?
Does anybody knows why i have a big difference between execution times of those requests that are the same but execute from different context against the same database ?
I verified all execution plans of both request and they use the same index to satisfy their respective query.
To see the execution plan of the C# request i use the SQL profiler to trap the Show Plan XML event and i compare it to the one of SSMS and both are the same.
Solution
Is this consistent, time after time?
I see a CPU difference which could be compile time. Are there any LINQ settings that affect this?
Edit:
I see a CPU difference which could be compile time. Are there any LINQ settings that affect this?
Edit:
- Capture the plans in Profiler
- Are you sure the SQL is the same in Profiler?
Context
StackExchange Database Administrators Q#1805, answer score: 6
Revisions (0)
No revisions yet.