Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

24 ms

Page Size

50

Current Page

329 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 329 Results Showing 16401 - 16450 of 24441

ID Name Category Price Stock Rating Reviews SKU
16960 Bulk Product 286442c7 Sports & Outdoors $528.61 488 2.8 92 BULK-77f83cb1
16961 Bulk Product 448c1cee Home & Garden $895.77 294 4.4 53 BULK-02f3af9d
16962 Bulk Product fd71b8d1 Sports & Outdoors $455.70 465 0.2 59 BULK-b4efcbf9
16963 Bulk Product b8c20390 Sports & Outdoors $562.23 321 3.9 79 BULK-c2d74a21
16964 Bulk Product 1ea151f5 Home & Garden $346.92 498 1.3 59 BULK-77364daa
16965 Bulk Product 126cc0dd Books $662.59 352 4.7 8 BULK-7e3a392c
16966 Bulk Product 2dd9f35e Toys & Games $437.26 110 1.1 46 BULK-4f051feb
16967 Bulk Product 89332499 Sports & Outdoors $837.79 194 0.6 28 BULK-4f1afa11
16968 Bulk Product 79d18b6c Home & Garden $664.85 483 3.6 63 BULK-a3e41ccd
16969 Bulk Product bf7efb19 Toys & Games $368.51 81 0.3 99 BULK-5bc25ba8
16970 Bulk Product a43104c8 Sports & Outdoors $162.58 249 4.3 3 BULK-8cfc34d8
16971 Bulk Product d87f7d7b Sports & Outdoors $917.50 293 1.5 81 BULK-43d96686
16972 Bulk Product 4892b372 Sports & Outdoors $208.32 252 1.8 9 BULK-585b34bd
16973 Bulk Product 22f0cc39 Sports & Outdoors $573.49 461 3.1 14 BULK-cbe6719f
16974 Bulk Product abd854d6 Books $167.27 93 1.3 49 BULK-e0469ed1
16975 Bulk Product 6dcd827d Clothing $640.92 152 2.8 90 BULK-7383b4c7
16976 Bulk Product aec98ca7 Electronics $467.84 363 5.0 51 BULK-cc57172c
16977 Bulk Product e45723e4 Clothing $649.54 171 4.5 91 BULK-5f965f8d
16978 Bulk Product 6dbc8a3b Toys & Games $168.99 172 3.2 26 BULK-3fc187ce
16979 Bulk Product 9c6f5550 Electronics $565.10 80 0.7 74 BULK-a7ae6ef5
16980 Bulk Product a6f72d94 Home & Garden $369.79 206 1.4 47 BULK-5e88b5bb
16981 Bulk Product a4b757f4 Home & Garden $972.27 343 1.2 29 BULK-36a8703a
16982 Bulk Product 163fc4d8 Electronics $933.13 436 1.8 27 BULK-12a83638
16983 Bulk Product 56b0ddd1 Books $901.81 351 2.3 6 BULK-023cc835
16984 Bulk Product c959cb9a Books $312.85 301 4.4 88 BULK-b0e99226
16985 Bulk Product 915af732 Sports & Outdoors $263.92 249 0.8 33 BULK-a07cd370
16986 Bulk Product e7c1510b Sports & Outdoors $705.18 430 1.5 55 BULK-0afbcf4c
16987 Bulk Product e6a71f13 Clothing $947.79 3 0.8 34 BULK-47b5c5ac
16988 Bulk Product 9cde905b Electronics $275.74 80 4.4 10 BULK-52b507c0
16989 Bulk Product e774f9e6 Electronics $44.21 266 2.0 40 BULK-196523e0
16990 Bulk Product 569701d0 Books $641.96 332 4.9 17 BULK-1b49eea9
16991 Bulk Product f1ff29dd Home & Garden $462.69 62 4.0 82 BULK-26628007
16992 Bulk Product e37c326c Toys & Games $915.71 160 3.4 2 BULK-efe295e0
16993 Bulk Product 683219bd Electronics $458.88 249 1.5 53 BULK-5e98bee8
16994 Bulk Product 29ba2435 Books $945.45 390 4.2 95 BULK-a26f6bae
16995 Bulk Product 83118733 Books $939.75 63 0.6 15 BULK-174248cb
16996 Bulk Product 75a7bfe5 Clothing $888.97 450 4.5 86 BULK-bdec3126
16997 Bulk Product 1321a006 Books $593.40 132 1.8 77 BULK-5b2a0661
16998 Bulk Product 9ccf082d Toys & Games $411.46 149 3.1 99 BULK-f3f708b1
16999 Bulk Product 7e283425 Sports & Outdoors $948.29 138 1.2 36 BULK-16e3f71c
17000 Bulk Product 6b510787 Toys & Games $383.52 115 3.5 31 BULK-e719acb7
17001 Bulk Product b7a5f626 Clothing $114.93 238 2.8 29 BULK-21474803
17002 Bulk Product d44ce237 Sports & Outdoors $92.97 59 3.7 71 BULK-570aa120
17003 Bulk Product dc7ec25d Clothing $60.66 139 3.7 32 BULK-5a65bab4
17004 Bulk Product dba1242c Books $171.86 412 0.4 85 BULK-5254569b
17005 Bulk Product 1a15a77c Home & Garden $591.28 9 0.2 50 BULK-115a43e7
17006 Bulk Product 74e3fbd2 Home & Garden $995.10 178 2.8 99 BULK-ae072415
17007 Bulk Product 2258d1c1 Books $870.69 464 3.8 89 BULK-85edb5db
17008 Bulk Product c6440b2a Books $985.00 102 4.5 54 BULK-91fde486
17009 Bulk Product f8419ae3 Electronics $962.37 470 3.8 11 BULK-aeaf02de
Implementation Code
// Efficient pagination with Skip and Take
public async Task<PaginatedResult<DemoProduct>> GetPaginatedProductsAsync(int page, int pageSize)
{
    // Get total count (cached if possible)
    var totalCount = await _context.DemoProducts.CountAsync(p => p.IsActive);
    
    // Get page of results
    var items = await _context.DemoProducts
        .Where(p => p.IsActive)
        .OrderBy(p => p.Id) // Important: Must have ORDER BY for consistent paging
        .Skip((page - 1) * pageSize) // OFFSET in SQL
        .Take(pageSize) // FETCH NEXT in SQL
        .AsNoTracking() // No tracking needed for read-only
        .ToListAsync();

    return new PaginatedResult<DemoProduct>
    {
        Items = items,
        TotalCount = totalCount,
        Page = page,
        PageSize = pageSize
    };
}
Pagination Best Practices
  • Always use OrderBy: Skip/Take require stable sorting for consistent results
  • Use AsNoTracking(): Pagination queries are typically read-only
  • Consider caching: Cache total count if dataset changes infrequently
  • Limit max page size: Prevent users from requesting too many records at once
  • Use indexed columns: Ensure ORDER BY columns are indexed for performance