Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

8 ms

Page Size

50

Current Page

111 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 111 Results Showing 5501 - 5550 of 24441

ID Name Category Price Stock Rating Reviews SKU
6060 Bulk Product fa18a911 Books $676.03 467 1.6 13 BULK-34e38f83
6061 Bulk Product 1e613757 Toys & Games $393.54 356 2.1 26 BULK-e12968a2
6062 Bulk Product 16a09d44 Books $935.10 22 4.1 84 BULK-a7416318
6063 Bulk Product dbbd8891 Clothing $519.52 433 1.0 65 BULK-2232c5e9
6064 Bulk Product 9d4b25a0 Clothing $880.55 284 1.8 43 BULK-699128d9
6065 Bulk Product 0630f3c6 Sports & Outdoors $34.36 389 2.7 84 BULK-f0b17f60
6066 Bulk Product b10fba29 Toys & Games $272.09 269 2.4 89 BULK-a273cc5c
6067 Bulk Product 06ff43c5 Books $203.49 116 3.5 97 BULK-687e4291
6068 Bulk Product 0fdfa734 Clothing $452.91 311 2.3 98 BULK-8265330a
6069 Bulk Product 990938fc Home & Garden $730.56 148 1.1 76 BULK-a4dab07c
6070 Bulk Product ceb1e0ba Books $10.76 452 3.4 35 BULK-6310b407
6071 Bulk Product 42569794 Electronics $500.75 453 0.8 90 BULK-9f381d07
6072 Bulk Product a17e4139 Books $325.59 402 0.4 28 BULK-f80eee20
6073 Bulk Product 7dc305f0 Sports & Outdoors $440.65 267 2.6 29 BULK-7d1013f8
6074 Bulk Product 792e0dfe Home & Garden $949.72 318 3.5 8 BULK-2fddb471
6075 Bulk Product b5ba9719 Electronics $230.39 1 3.8 25 BULK-4e8af2ba
6076 Bulk Product 4a04247a Toys & Games $142.34 328 0.2 57 BULK-2df895f4
6077 Bulk Product a8c7f2bc Clothing $255.67 138 2.8 7 BULK-435a736a
6078 Bulk Product fe0bcccf Sports & Outdoors $981.73 88 1.9 19 BULK-fa98dcde
6079 Bulk Product f99c7d68 Electronics $772.79 368 1.7 5 BULK-84e69ad2
6080 Bulk Product 5994a25a Books $198.86 295 0.8 32 BULK-37c2c653
6081 Bulk Product d486511d Clothing $121.59 96 2.9 30 BULK-dd4e4bcb
6082 Bulk Product aeb4976b Clothing $814.88 7 3.5 98 BULK-dc79296c
6083 Bulk Product cc2a0adb Books $723.63 422 1.5 12 BULK-98636f82
6084 Bulk Product 3b3d5f82 Toys & Games $34.97 366 2.3 61 BULK-eac79c6b
6085 Bulk Product bc1a365b Clothing $56.64 118 1.3 1 BULK-4dc29072
6086 Bulk Product 4c50428a Toys & Games $465.53 461 4.6 35 BULK-98b78d49
6087 Bulk Product 016272dd Clothing $171.48 304 1.9 46 BULK-592220c7
6088 Bulk Product 87da7768 Clothing $84.24 331 0.6 58 BULK-3f005492
6089 Bulk Product 89c5df78 Home & Garden $493.10 131 4.4 36 BULK-7718a1ec
6090 Bulk Product 0c2d6a25 Clothing $835.28 333 0.5 92 BULK-4abffd16
6091 Bulk Product b0e43cbe Clothing $388.68 319 3.8 80 BULK-ba547faf
6092 Bulk Product 95b8169e Books $144.07 490 1.7 36 BULK-e30051e3
6093 Bulk Product 8f121efa Books $586.82 145 3.4 52 BULK-963789e7
6094 Bulk Product e5aafaff Home & Garden $130.51 154 5.0 39 BULK-66e8106e
6095 Bulk Product 86271921 Clothing $628.01 297 2.1 76 BULK-d38f5c32
6096 Bulk Product 2fef5686 Clothing $66.22 19 1.5 63 BULK-8bbed0a3
6097 Bulk Product 6b607ba7 Toys & Games $749.49 342 2.3 91 BULK-3532523f
6098 Bulk Product 4133597b Home & Garden $503.82 16 1.7 19 BULK-e51a57ec
6099 Bulk Product 0e126b66 Home & Garden $534.35 70 1.3 39 BULK-8d821008
6100 Bulk Product 439805f8 Sports & Outdoors $269.22 130 3.1 77 BULK-04df6cf0
6101 Bulk Product 6f4e18f7 Home & Garden $683.70 294 0.5 87 BULK-bafc70b4
6102 Bulk Product 28b9f996 Home & Garden $472.31 0 2.7 31 BULK-79c2b030
6103 Bulk Product 80124146 Clothing $501.94 258 3.4 85 BULK-9cfb2572
6104 Bulk Product 0acecb0b Toys & Games $280.00 102 2.0 7 BULK-7ccff77f
6105 Bulk Product 3e4e1415 Clothing $449.68 187 3.3 65 BULK-d7a68ad3
6106 Bulk Product bf4daaa8 Sports & Outdoors $583.09 381 4.4 63 BULK-96222327
6107 Bulk Product 65b3d7e3 Toys & Games $703.75 283 2.7 68 BULK-9a8e8600
6108 Bulk Product 6217cc67 Sports & Outdoors $358.96 241 4.8 43 BULK-5565c036
6109 Bulk Product 503e9e34 Books $676.18 53 2.2 97 BULK-2aaefb19
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