Hello,
We are using Kendo.MVC, version 2020.1.400. We use microsoft sql server 2017. Our database is case insensitive.
When kendo grid request comes in, we translate Kendo's sort, paging, etc into ISpecification in SharpRepository and we let SharpRepository to handle the sql communication.
We recently made the code change that we skip SharpRepository and use Kendo extension ToDataSourceResult() to deal with sql server.
For large data set, we find the new approach takes much longer time to show the Kendo grid. After investigation, I found that the sql generated by Kendo contains LOWER() for columns! Below is an example. However, in SQL Server, when you use LOWER for a column, the index for that column is not used! It has to do clustered index scan, which is very slow.
I saw an old post saying LOWER() is built in behavior and no way to change it. https://www.telerik.com/forums/grid-filtering-on-text-using-lower-in-sql
I wonder if the latest kendo can allow the user to disable LOWER() behavior. it is very straightforward for your company to fix it, basically providing an additional boolean parameter to ToDataSourceResult() to enable or disable LOWER(). A small thing for Kendo but a big thing for us. Currently if LOWER() can't be removed, we have to go back to the old approach by using SharpRepository. the sql generated by SharpRepository doesn't include LOWER. Our database is case insensitive, so LOWER() is really unnecessary and it is a performance bottleneck.
Please please please fix it.
SELECT
[Extent1].[UserId] AS [UserId],
[Extent1].[Id] AS [Id],
[Extent1].Blah
FROM [dbo].[UserFilteredWorkbenchItems] AS [Extent1]WHERE (((LOWER([Extent1].[UserId])) = (LOWER(N'881d796c-9c88-ea11-99e7-0003ff77da57'))) OR ((LOWER([Extent1].[UserId]) IS NULL) AND (LOWER(N'881d796c-9c88-ea11-99e7-0003ff77da57') IS NULL))) AND (((LOWER([Extent1].[FilterByUnit])) = (LOWER(N''))) OR ((LOWER([Extent1].[FilterByUnit]) IS NULL) AND (LOWER(N'') IS NULL)))
ORDER BY row_number() OVER (ORDER BY [Extent1].[Priority] ASC)
OFFSET 160 ROWS FETCH NEXT 20 ROWS ONLY
Best regards
Frank