LLBGen 5.3 & MS SQL Server 2012: paging query but no OFFSET xxx FETCH in generated SQL

Posts   
 
    
sasaki
User
Posts: 6
Joined: 23-May-2019
# Posted on: 23-May-2019 11:11:38   

LLBLGen 5.3

I query data in a collection like this:

collection.GetMulti(filter, 0, sorter, relations, path, 1, 10);

but generated SQL don't have OFFSET xxx FETCH xxx

Generated SQL:

    SELECT
        ...
    FROM
        ((((
                        [NewsDB].[dbo].[Article]
                        INNER JOIN [NewsDB].[dbo].[OnlineArticle] ON [NewsDB].[dbo].[Article].[ArticleID] = [NewsDB].[dbo].[OnlineArticle].[OnlineArticleID] 
                        )
                    INNER JOIN [NewsDB].[dbo].[CategoryOnlineArticle] ON [NewsDB].[dbo].[OnlineArticle].[OnlineArticleID] = [NewsDB].[dbo].[CategoryOnlineArticle].[OnlineArticleID] 
                    )
                INNER JOIN [NewsDB].[dbo].[Category] ON [NewsDB].[dbo].[Category].[CategoryID] = [NewsDB].[dbo].[CategoryOnlineArticle].[CategoryID] 
                )
            LEFT JOIN [NewsDB].[dbo].[OldOnlineArticle] ON [NewsDB].[dbo].[OnlineArticle].[OnlineArticleID] = [NewsDB].[dbo].[OldOnlineArticle].[OnlineArticleID] 
        ) 
    WHERE
        (
            (
                (
                    [NewsDB].[dbo].[Article].[IsDeleted] = @p1 
                    AND [NewsDB].[dbo].[Article].[IsArchive] = @p2 
                    AND [NewsDB].[dbo].[Article].[NavigateType] = @p3 
                    AND [NewsDB].[dbo].[Article].[Status] = @p4 
                    AND [NewsDB].[dbo].[OnlineArticle].[IsOnlinePublished] = @p5 
                    AND [NewsDB].[dbo].[OnlineArticle].[OnlinePublishDateUtc] <= @p6 
                ) 
                AND [NewsDB].[dbo].[OnlineArticle].[SiteNewsPortalID] = @p7 
                AND [NewsDB].[dbo].[Category].[IsDeleted] = @p8 
                AND [NewsDB].[dbo].[Category].[IsEnable] = @p9 
                AND [NewsDB].[dbo].[Category].[CategoryType] = @p10 
                AND [NewsDB].[dbo].[Category].[CategoryID] = @p11 
            ) 
        AND ( [NewsDB].[dbo].[OnlineArticle].[OnlineArticleID] IS NOT NULL )) 
    ORDER BY
        [NewsDB].[dbo].[OnlineArticle].[RefreshDateUtc] DESC,
        [NewsDB].[dbo].[OnlineArticle].[OnlinePublishDateUtc] DESC

=========

I think this caused performance issue in our site, but don't know how to solve. Please help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-May-2019 13:31:36   

you specify a paging directive, which requires 'distinct'. Do you have fields of type varchar(max) or other large fields in the select list (the '...' in the query) which cause the query to switch to client side paging? (it will fetch as much rows as needed to satisfy the paging directive so it's not all bad, but on the server it's faster of course).

So what are the field types of the fields in the collection you're fetching?

Frans Bouma | Lead developer LLBLGen Pro
sasaki
User
Posts: 6
Joined: 23-May-2019
# Posted on: 31-May-2019 05:30:36   

Thanks @Otis, your information help me so much.

Otis wrote:

you specify a paging directive, which requires 'distinct'. Do you have fields of type varchar(max) or other large fields in the select list (the '...' in the query) which cause the query to switch to client side paging? (it will fetch as much rows as needed to satisfy the paging directive so it's not all bad, but on the server it's faster of course).

So what are the field types of the fields in the collection you're fetching?