Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

23 ms

Page Size

50

Current Page

185 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 185 Results Showing 9201 - 9250 of 24441

ID Name Category Price Stock Rating Reviews SKU
9760 Bulk Product 0ff7905d Electronics $649.14 155 3.9 73 BULK-05b185c7
9761 Bulk Product 1bbeba5a Electronics $258.10 15 0.6 39 BULK-61571ae5
9762 Bulk Product f2692769 Electronics $256.04 491 4.5 28 BULK-5dc8c3d3
9763 Bulk Product d027db5d Toys & Games $348.52 431 3.6 62 BULK-06efdde3
9764 Bulk Product 9d9ac6da Toys & Games $100.92 6 1.1 61 BULK-0f332b94
9765 Bulk Product ac217105 Books $503.65 140 3.7 31 BULK-03228371
9766 Bulk Product 5c62b26a Home & Garden $92.66 199 1.5 50 BULK-01c594e5
9767 Bulk Product 969123dc Clothing $129.62 494 2.4 95 BULK-8d85f74d
9768 Bulk Product 5065c6a8 Sports & Outdoors $812.17 361 1.8 73 BULK-a64b7d3d
9769 Bulk Product 4ba84c3d Sports & Outdoors $571.93 207 2.4 47 BULK-38a969a7
9770 Bulk Product bd99a64c Electronics $837.90 460 1.6 23 BULK-26203eae
9771 Bulk Product 9073dd6d Books $713.46 38 0.5 79 BULK-965dc645
9772 Bulk Product d592d0b9 Toys & Games $605.16 339 3.9 38 BULK-1f2f094b
9773 Bulk Product 8da0b12e Home & Garden $239.17 135 2.0 68 BULK-9d9da534
9774 Bulk Product 54f40e02 Toys & Games $95.48 435 2.6 62 BULK-3d726535
9775 Bulk Product 96f36b01 Home & Garden $670.81 441 2.7 21 BULK-f9ad696e
9776 Bulk Product 8fa7a7f6 Sports & Outdoors $342.49 311 4.0 52 BULK-0777fe69
9777 Bulk Product 1d4ba6e1 Sports & Outdoors $925.38 119 2.2 23 BULK-bf10bbfa
9778 Bulk Product d5cdabc0 Toys & Games $268.38 94 0.2 27 BULK-efe13dd6
9779 Bulk Product 5b8fbc72 Home & Garden $746.09 468 1.3 15 BULK-488ffc64
9780 Bulk Product b15b6635 Clothing $323.83 55 1.7 49 BULK-0698b224
9781 Bulk Product 617c28b5 Home & Garden $787.10 61 1.0 97 BULK-d1c04806
9782 Bulk Product 3dac87dc Toys & Games $911.48 408 0.6 78 BULK-3da84c3f
9783 Bulk Product 5d4e01ee Books $62.90 317 4.9 84 BULK-de9dae18
9784 Bulk Product 57421890 Sports & Outdoors $938.85 470 1.0 59 BULK-0eacbf40
9785 Bulk Product f6090ee1 Home & Garden $287.33 185 1.3 78 BULK-b0a13c5d
9786 Bulk Product a1f1f4b5 Electronics $922.84 199 3.5 8 BULK-050acfbe
9787 Bulk Product 75124496 Toys & Games $753.79 178 0.6 16 BULK-f988ea2b
9788 Bulk Product 820844e7 Sports & Outdoors $989.01 436 0.0 84 BULK-617866ca
9789 Bulk Product dc4330d4 Books $441.27 290 0.8 37 BULK-e05842a0
9790 Bulk Product d3acf228 Toys & Games $796.17 327 2.7 43 BULK-b350af3d
9791 Bulk Product ce558c11 Toys & Games $509.46 343 4.9 25 BULK-faafe764
9792 Bulk Product 722c42fd Sports & Outdoors $1,006.60 302 4.4 83 BULK-00b95c63
9793 Bulk Product 3a4de7ae Toys & Games $802.85 429 2.5 70 BULK-83fcdb12
9794 Bulk Product 5f6e985e Sports & Outdoors $919.77 408 3.4 28 BULK-2578fb16
9795 Bulk Product 96397ee0 Books $905.74 43 1.1 74 BULK-291f8067
9796 Bulk Product 22bd44b3 Sports & Outdoors $26.08 62 0.7 27 BULK-62fa1f6a
9797 Bulk Product 8be2af79 Toys & Games $787.51 6 3.0 65 BULK-5d908f7b
9798 Bulk Product 32b38f12 Clothing $136.17 142 0.7 67 BULK-ce2cee8a
9799 Bulk Product 7916ae4f Clothing $756.42 265 0.5 50 BULK-933ecd9a
9800 Bulk Product 633a2031 Home & Garden $233.54 346 1.7 3 BULK-8b7fa9c5
9801 Bulk Product 12c8af5d Electronics $553.87 441 2.3 67 BULK-1017f568
9802 Bulk Product cbeef629 Electronics $503.81 240 0.4 42 BULK-19a20433
9803 Bulk Product 2ecede9c Books $326.39 114 2.2 84 BULK-725417a7
9804 Bulk Product e81aafb1 Home & Garden $427.35 279 0.3 31 BULK-8286284a
9805 Bulk Product 10d45009 Sports & Outdoors $802.12 308 4.1 21 BULK-b08a6238
9806 Bulk Product cc2f7ef0 Books $630.84 224 0.3 32 BULK-e9bad3c5
9807 Bulk Product aba14e35 Books $111.61 404 2.9 56 BULK-c58e6311
9808 Bulk Product f11d276f Home & Garden $660.70 9 1.4 58 BULK-1022e07f
9809 Bulk Product 4df996e1 Home & Garden $846.96 307 2.9 22 BULK-fc64db05
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