Otis wrote:
to get TOP (@param), don't set the compatibility mode to sqlserver 2000, the default is 2005+ which will emit top (@param)
LLBL is emitting TOP (@param) - still slow.
Full LLLBL generated query from ORMProfiler:
SELECT TOP(10 /* @p2 */) [LPA_L1].[InvestigationTitle],
[LPA_L1].[WRType],
[LPA_L1].[WRNumber],
[LPA_L1].[WRPeriod],
[LPA_L1].[State],
[LPA_L1].[TargetEndDateTime],
[LPA_L1].[TargetStartDateTime],
[LPA_L1].[ActualEndDateTime],
[LPA_L1].[ActualStartDateTime],
[LPA_L1].[EstimatedHours],
[LPA_L1].[Owner],
[LPA_L1].[PrioritySort],
[LPA_L1].[RelatedOccurrenceIDs],
[LPA_L1].[IsRestricted],
[LPA_L1].[Overdue],
[LPA_L1].[CheckedoutToWorkbenchUser]
FROM (SELECT DISTINCT [LPLA_1].[Title] AS [InvestigationTitle],
[LPLA_1].[WR_Type] AS [WRType],
[LPLA_1].[WR_Number] AS [WRNumber],
[LPLA_1].[WR_Period] AS [WRPeriod],
[LPLA_1].[State],
[LPLA_1].[Target_End_Date] AS [TargetEndDateTime],
[LPLA_1].[Target_Start_Date] AS [TargetStartDateTime],
[LPLA_1].[Actual_End_Date] AS [ActualEndDateTime],
[LPLA_1].[Actual_Start_Date] AS [ActualStartDateTime],
[LPLA_1].[Estimated_hours] AS [EstimatedHours],
[LPLA_1].[Owner_Department_Name] AS [Owner],
[LPLA_1].[PrioritySort],
[LPLA_1].[Related_Occurrences] AS [RelatedOccurrenceIDs],
[LPLA_1].[Restricted] AS [IsRestricted],
[LPLA_1].[OverDue] AS [Overdue],
[LPLA_1].[ChkOutTo] AS [CheckedoutToWorkbenchUser]
FROM [AQD].[qaoc_WR_ViewSecurity] [LPLA_1]
WHERE (((((([LPLA_1].[Staff_Member_ID] = 437 /* @p3 */))
AND ([LPLA_1].[WR_Type_Sub_Group_ID] = 10 /* @p4 */))
AND ([LPLA_1].[State] IN ('Assigned' /* @p5 */, 'Opened' /* @p6 */, 'In Progress' /* @p7 */, 'Findings Issued' /* @p8 */)))))) [LPA_L1]
ORDER BY [LPA_L1].[WRPeriod] DESC,
[LPA_L1].[WRType] DESC,
[LPA_L1].[WRNumber] DESC