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
When without set UseCompatibilityLevel to 120, it generates query as below:
exec sp_executesql N'SELECT [t0].[TenantId], [t0].[GroupId], [t0].[GroupName], [t0].[GroupTypeId]
FROM [MeterGroupRouteIndex] AS [m]
INNER JOIN (
SELECT [m0].[GroupId], [m0].[GroupName], [m0].[GroupTypeId], [m0].[TenantId]
FROM [MeterGroup] AS [m0]
WHERE [m0].[TenantId] IN (
SELECT [t].[value]
FROM OPENJSON(@__tenantIds_1) WITH ([value] int ''$'') AS [t]
)
) AS [t0] ON [m].[ParentGroupId] = [t0].[GroupId]
WHERE CASE
WHEN [m].[ChildGroupId] = @__id_0 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END & CASE
WHEN [m].[ParentGroupId] <> @__id_0 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END = CAST(1 AS bit) AND [t0].[GroupTypeId] IN (
SELECT [t1].[value]
FROM OPENJSON(@__typeIds_2) WITH ([value] int ''$'') AS [t1]
)',N'@__tenantIds_1 nvarchar(4000),@__id_0 int,@__typeIds_2 nvarchar(4000)',@__tenantIds_1=N'[2,5,6,7,12,1,-1]',@__id_0=160178,@__typeIds_2=N'[40,47,61,62,63,64,65,66,71,72,73,74,75,76,77,89,90,91,92,93,94,136,137,138,160,163,213,215,223,230,231,232,233,238,239,240,241]'
This query took nearly 30 seconds to execute, with exeution plan as below:
When with set UseCompatibilityLevel to 120, it generates query as below:
exec sp_executesql N'SELECT [t].[TenantId], [t].[GroupId], [t].[GroupName], [t].[GroupTypeId]
FROM [MeterGroupRouteIndex] AS [m]
INNER JOIN (
SELECT [m0].[GroupId], [m0].[GroupName], [m0].[GroupTypeId], [m0].[TenantId]
FROM [MeterGroup] AS [m0]
WHERE [m0].[TenantId] IN (2, 5, 6, 7, 12, 1, -1)
) AS [t] ON [m].[ParentGroupId] = [t].[GroupId]
WHERE CASE
WHEN [m].[ChildGroupId] = @__id_0 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END & CASE
WHEN [m].[ParentGroupId] <> @__id_0 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END = CAST(1 AS bit) AND [t].[GroupTypeId] IN (40, 47, 61, 62, 63, 64, 65, 66, 71, 72, 73, 74, 75, 76, 77, 89, 90, 91, 92, 93, 94, 136, 137, 138, 160, 163, 213, 215, 223, 230, 231, 232, 233, 238, 239, 240, 241)',N'@__id_0 int',@__id_0=160178
This query took less than 1 seconds to execute, with exeution plan as below:
Include stack traces
NA
Include verbose output
NA
Include provider and version information
EF Core version: 8.0.5
Database provider: 16.0.4085.2
Target framework: NET 8.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.10.3
The text was updated successfully, but these errors were encountered:
File a bug
Technically it's a query optimization issue, but was not expecting such dramatic performance drop when using the new change:
intead of
Include your code
This query took nearly 30 seconds to execute, with exeution plan as below:
This query took less than 1 seconds to execute, with exeution plan as below:
Include stack traces
NA
Include verbose output
NA
Include provider and version information
EF Core version: 8.0.5
Database provider: 16.0.4085.2
Target framework: NET 8.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.10.3
The text was updated successfully, but these errors were encountered: