You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT [t].[CustomerId], CASE
WHEN COUNT(*) =0 THEN 0
ELSE DATEDIFF(day, MIN([t].[TransactionDate]), MAX([t].[TransactionDate])) /COUNT(*)
END AS [avg]
FROM [Transactions] AS [t]
GROUP BY [t].[CustomerId]
Execution Time:
SQL Server Execution Times:
CPU time = 125 ms, elapsed time = 325 ms.
SELECT [t].[CustomerId], CASE
WHEN NOT (EXISTS (
SELECT1FROM [Transactions] AS [t0]
WHERE [t].[CustomerId] = [t0].[CustomerId])) THEN 0
ELSE DATEDIFF(day, MIN([t].[TransactionDate]), MAX([t].[TransactionDate])) /COUNT(*)
END AS [avg]
FROM [Transactions] AS [t]
GROUP BY [t].[CustomerId]
Execution Time:
SQL Server Execution Times:
CPU time = 266 ms, elapsed time = 401 ms.
sa-es-ir
changed the title
Query Translation: different between x.Count()==0 and !x.Any()
Query Translation: difference between x.Count()==0 and !x.Any()
May 5, 2022
I have a performance issue with EF and translated query
With this code
And the translated query is like:
Execution Time:
But for this code
And the translated query:
Execution Time:
I think both of them should be a same query.
Include provider and version information
EF Core version: 6.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
The text was updated successfully, but these errors were encountered: