Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

25 ms

Page Size

50

Current Page

369 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 369 Results Showing 18401 - 18450 of 24441

ID Name Category Price Stock Rating Reviews SKU
18960 Bulk Product ac89cde3 Toys & Games $95.94 416 3.6 24 BULK-5176bc5d
18961 Bulk Product 9a06c842 Sports & Outdoors $462.79 374 4.7 63 BULK-4b317344
18962 Bulk Product 6886b4fd Toys & Games $390.12 307 4.2 93 BULK-07bccc1a
18963 Bulk Product 46bda540 Home & Garden $167.68 83 3.9 25 BULK-6a91eda3
18964 Bulk Product 7800e565 Clothing $100.34 92 3.2 29 BULK-957bad87
18965 Bulk Product 0f7a1759 Sports & Outdoors $988.44 400 3.4 83 BULK-7a61e761
18966 Bulk Product 6de7a4f8 Toys & Games $553.69 365 4.8 5 BULK-485c65a4
18967 Bulk Product bdfa6b63 Home & Garden $494.42 356 3.1 74 BULK-c6f86053
18968 Bulk Product e428a4ef Sports & Outdoors $421.84 76 0.1 51 BULK-9e10322a
18969 Bulk Product 671036c2 Clothing $103.48 282 0.9 12 BULK-1f7168a9
18970 Bulk Product 0c2e1a2a Electronics $121.58 106 0.4 36 BULK-8a260881
18971 Bulk Product ccb1e03b Toys & Games $919.04 143 4.7 3 BULK-a02d03be
18972 Bulk Product ea954345 Books $750.80 274 2.7 43 BULK-a0fcb9b2
18973 Bulk Product 35cb6fa4 Toys & Games $79.02 3 3.7 93 BULK-18085ac9
18974 Bulk Product ae7237ea Clothing $660.71 117 4.3 62 BULK-ccd1f826
18975 Bulk Product afebe42c Books $608.01 419 0.5 44 BULK-29d422b1
18976 Bulk Product 0999eac9 Toys & Games $242.22 314 4.8 50 BULK-10b2cff2
18977 Bulk Product 9a4fb799 Electronics $913.60 106 4.1 64 BULK-9a5ebea0
18978 Bulk Product 935dc1b3 Electronics $319.07 215 1.2 68 BULK-29e9feed
18979 Bulk Product 876c14cb Home & Garden $804.57 209 1.0 66 BULK-a4d7ff5b
18980 Bulk Product e09497d3 Electronics $18.45 214 1.6 52 BULK-e891e777
18981 Bulk Product 8386090a Books $511.85 451 3.3 82 BULK-9d40c17d
18982 Bulk Product fc60410e Home & Garden $759.16 237 0.2 60 BULK-73ced806
18983 Bulk Product 7b994d3d Home & Garden $545.99 18 2.0 31 BULK-282ca385
18984 Bulk Product 676a54e9 Books $59.90 495 3.0 61 BULK-c1b9c9ec
18985 Bulk Product 189f6384 Books $794.02 169 3.9 64 BULK-99b08967
18986 Bulk Product a98caeb4 Electronics $275.21 213 4.5 94 BULK-2c2127ac
18987 Bulk Product 7d7e85e3 Clothing $108.14 266 4.6 51 BULK-b0089aeb
18988 Bulk Product 2aac6ec4 Home & Garden $616.48 327 2.6 4 BULK-07dcff1d
18989 Bulk Product 11409f7c Sports & Outdoors $826.06 464 0.7 26 BULK-c610c7f4
18990 Bulk Product a3047527 Electronics $413.02 482 2.2 4 BULK-9a2380ea
18991 Bulk Product a8ac7c80 Clothing $573.38 332 0.9 96 BULK-e050a2b2
18992 Bulk Product b7447932 Clothing $810.00 370 0.5 77 BULK-6c58225e
18993 Bulk Product 3a89cbcb Books $904.76 129 5.0 4 BULK-01a160df
18994 Bulk Product 78660b0b Sports & Outdoors $456.03 180 0.5 2 BULK-599948b9
18995 Bulk Product 4af2b64b Home & Garden $402.39 168 2.3 29 BULK-72a94e6b
18996 Bulk Product 6dda880e Sports & Outdoors $612.44 402 0.5 70 BULK-c7a0e676
18997 Bulk Product 1f382cb9 Books $255.80 127 0.3 19 BULK-ea70c169
18998 Bulk Product a56bdac5 Clothing $280.80 212 3.4 11 BULK-8193b530
18999 Bulk Product d3df993e Electronics $472.51 458 0.3 16 BULK-086ce1ee
19000 Bulk Product 0e91a6f2 Clothing $522.78 284 1.0 46 BULK-7bd56708
19001 Bulk Product f87850ea Toys & Games $323.53 189 3.5 44 BULK-1612db1a
19002 Bulk Product cbefbefa Home & Garden $525.16 119 2.9 24 BULK-590325ff
19003 Bulk Product 729e53c8 Sports & Outdoors $373.02 391 4.3 22 BULK-8c720f02
19004 Bulk Product 650329e0 Books $758.49 426 4.0 1 BULK-b1e312e7
19005 Bulk Product 41b8e310 Sports & Outdoors $970.12 209 1.2 50 BULK-75df1a04
19006 Bulk Product 7e96dff9 Toys & Games $919.64 302 2.3 9 BULK-d736fafe
19007 Bulk Product aaa4501a Clothing $333.26 310 0.7 94 BULK-294e6902
19008 Bulk Product 58a922ef Home & Garden $352.74 411 1.7 32 BULK-eedf5ff5
19009 Bulk Product a2b33218 Clothing $140.17 92 3.3 73 BULK-0e5a52fa
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