Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

13 ms

Page Size

50

Current Page

163 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 163 Results Showing 8101 - 8150 of 24441

ID Name Category Price Stock Rating Reviews SKU
8660 Bulk Product e855886e Toys & Games $20.38 463 4.0 26 BULK-9524c475
8661 Bulk Product 67f03861 Sports & Outdoors $954.38 487 4.5 1 BULK-0092c202
8662 Bulk Product 83afa2e6 Toys & Games $908.66 117 1.3 69 BULK-3bc7ca1f
8663 Bulk Product 914ecde5 Electronics $95.35 318 0.0 34 BULK-8d529e2d
8664 Bulk Product b11138f5 Electronics $520.37 460 1.1 28 BULK-03645cb9
8665 Bulk Product b9f66961 Toys & Games $670.06 437 2.1 20 BULK-15f00126
8666 Bulk Product 8c7eadd4 Toys & Games $856.58 289 3.8 6 BULK-94875090
8667 Bulk Product ebdf083b Toys & Games $453.35 110 5.0 19 BULK-80cf0a1c
8668 Bulk Product 555c219d Clothing $777.36 239 0.2 26 BULK-3bb15804
8669 Bulk Product 41b64041 Home & Garden $461.40 416 1.2 25 BULK-0912fbcf
8670 Bulk Product 82f0d367 Sports & Outdoors $393.90 304 2.1 94 BULK-a899022f
8671 Bulk Product db29e0c8 Toys & Games $576.77 364 0.6 57 BULK-74198c9a
8672 Bulk Product babf1726 Electronics $439.73 124 3.8 23 BULK-a605e2d4
8673 Bulk Product 17e29972 Electronics $214.06 29 1.1 50 BULK-ec9ea786
8674 Bulk Product 5c321b3c Home & Garden $493.34 60 0.7 36 BULK-911655d8
8675 Bulk Product 032ec4c9 Home & Garden $763.97 365 0.7 53 BULK-005b5edf
8676 Bulk Product b553f6b8 Toys & Games $693.54 150 2.2 0 BULK-044ce6a2
8677 Bulk Product cf2eca0a Sports & Outdoors $759.13 286 3.9 30 BULK-18329699
8678 Bulk Product 3eb4a9de Sports & Outdoors $570.54 447 3.2 93 BULK-f65c47e7
8679 Bulk Product feeba1e9 Sports & Outdoors $618.30 351 1.3 51 BULK-2789def5
8680 Bulk Product c3acd847 Clothing $810.27 309 0.3 83 BULK-9e6a2d81
8681 Bulk Product 6bc94178 Clothing $138.42 179 2.2 96 BULK-f42be5d5
8682 Bulk Product af3b9058 Clothing $763.89 334 2.1 70 BULK-cf586753
8683 Bulk Product 70cff6c3 Toys & Games $1,002.12 246 3.3 75 BULK-d03d1195
8684 Bulk Product 200536f8 Sports & Outdoors $647.67 138 2.1 96 BULK-fce5e356
8685 Bulk Product 845f24d1 Sports & Outdoors $180.46 228 3.3 79 BULK-3abfd69d
8686 Bulk Product f1a70eb2 Sports & Outdoors $830.06 466 4.5 15 BULK-8edbe18e
8687 Bulk Product 890e3f27 Toys & Games $484.03 177 0.5 78 BULK-541d98dc
8688 Bulk Product 0367091a Toys & Games $606.35 303 5.0 74 BULK-cfe31784
8689 Bulk Product ac4f0283 Toys & Games $801.28 29 2.7 38 BULK-0778a6b3
8690 Bulk Product 1bcd6f62 Toys & Games $118.79 392 0.7 45 BULK-c7713180
8691 Bulk Product 5395d2cb Clothing $79.61 137 4.9 74 BULK-571ad4e0
8692 Bulk Product ab12b198 Books $829.87 144 0.3 31 BULK-da293a43
8693 Bulk Product b849da9a Electronics $68.13 271 1.1 13 BULK-15fca790
8694 Bulk Product b3b178b7 Books $490.44 127 2.4 20 BULK-6ee25552
8695 Bulk Product 229af3d0 Home & Garden $41.47 13 2.5 32 BULK-a3b00dd4
8696 Bulk Product e0237ac4 Clothing $46.51 110 0.7 34 BULK-15f6c4e4
8697 Bulk Product 853dfdd2 Toys & Games $224.39 371 2.9 66 BULK-e2410457
8698 Bulk Product f25338b1 Electronics $759.76 279 4.9 89 BULK-96985a6b
8699 Bulk Product 6c27528f Clothing $81.88 459 4.3 66 BULK-47632004
8700 Bulk Product ad76ab9c Toys & Games $507.35 483 4.4 47 BULK-4ef67042
8701 Bulk Product da35d0a7 Electronics $42.19 466 0.4 33 BULK-4d3f9b7b
8702 Bulk Product 331c2487 Books $697.31 143 3.3 5 BULK-6206088d
8703 Bulk Product ef24a1c7 Clothing $459.64 183 0.8 48 BULK-6a2a5ad1
8704 Bulk Product 0dbfc6bf Toys & Games $260.03 239 0.3 53 BULK-fd5b0466
8705 Bulk Product 916718ec Sports & Outdoors $796.79 41 2.2 23 BULK-2405ee74
8706 Bulk Product f90729ac Books $930.16 11 3.3 22 BULK-09a23243
8707 Bulk Product 4b2787e9 Electronics $492.75 84 2.7 52 BULK-48680ed3
8708 Bulk Product 8a1ae9fd Clothing $876.16 48 0.6 68 BULK-87d30500
8709 Bulk Product a1c03810 Clothing $979.30 54 1.0 85 BULK-76a9d3ce
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