Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

27 ms

Page Size

50

Current Page

244 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 244 Results Showing 12151 - 12200 of 24441

ID Name Category Price Stock Rating Reviews SKU
12710 Bulk Product c8e37037 Books $613.52 144 0.5 21 BULK-f98d993a
12711 Bulk Product cf34af47 Sports & Outdoors $859.62 296 3.0 68 BULK-2172f05d
12712 Bulk Product 297b4200 Clothing $783.31 428 0.6 41 BULK-532f407e
12713 Bulk Product 4e9a9745 Home & Garden $628.91 275 0.2 78 BULK-3092028e
12714 Bulk Product 6bdd662f Clothing $219.65 98 3.7 83 BULK-82e68483
12715 Bulk Product 201c01bd Sports & Outdoors $103.19 257 1.4 96 BULK-1702ed68
12716 Bulk Product db9d81e0 Books $144.34 127 1.9 86 BULK-209ef429
12717 Bulk Product 64fe5bcf Electronics $909.82 487 1.0 35 BULK-b7784a47
12718 Bulk Product 1a2eaf07 Books $603.64 465 0.5 81 BULK-473097ea
12719 Bulk Product f51791b8 Clothing $704.43 98 2.5 58 BULK-86121450
12720 Bulk Product 7d8c5037 Toys & Games $656.83 263 3.4 68 BULK-7fa049b5
12721 Bulk Product 12009185 Clothing $416.20 432 1.3 40 BULK-174f0955
12722 Bulk Product 48730de3 Sports & Outdoors $913.24 53 3.9 53 BULK-81b8184e
12723 Bulk Product b74dd834 Sports & Outdoors $694.02 51 4.2 18 BULK-f61f0fc2
12724 Bulk Product a1f8fbd8 Books $314.47 169 2.6 23 BULK-ec77cdda
12725 Bulk Product 332227fd Clothing $865.99 214 0.5 25 BULK-5baa1222
12726 Bulk Product 3e3ab0e7 Clothing $87.34 254 3.0 92 BULK-d50ddf7c
12727 Bulk Product cdc55a72 Electronics $212.15 198 2.2 55 BULK-e91b936e
12728 Bulk Product b459bd9d Toys & Games $423.43 359 2.9 26 BULK-df6f7e30
12729 Bulk Product de99bab5 Home & Garden $30.23 452 4.6 60 BULK-ca4245ea
12730 Bulk Product 6145a33e Books $682.81 21 0.7 85 BULK-3aeef61d
12731 Bulk Product ab0a0c8c Books $715.68 205 1.6 80 BULK-ffc7ee0b
12732 Bulk Product 0312f33c Clothing $916.32 499 4.0 70 BULK-c1ace2f2
12733 Bulk Product 2d8c5957 Home & Garden $634.41 466 3.7 16 BULK-12e37c4c
12734 Bulk Product 66038ada Sports & Outdoors $187.76 297 2.2 53 BULK-5f1f8064
12735 Bulk Product 048d7a9b Clothing $588.59 97 3.3 34 BULK-b6e46574
12736 Bulk Product 4e5f3642 Toys & Games $382.10 109 0.9 9 BULK-c71990f0
12737 Bulk Product b7e70761 Sports & Outdoors $255.76 413 3.7 90 BULK-2057d681
12738 Bulk Product f31e6707 Electronics $239.55 22 3.4 68 BULK-b6417f82
12739 Bulk Product bf0c6de4 Home & Garden $76.23 422 3.5 39 BULK-2b7183b2
12740 Bulk Product 8ee96939 Electronics $19.11 108 0.8 17 BULK-a323049c
12741 Bulk Product 1de0956f Toys & Games $486.77 111 1.0 32 BULK-4872ba5d
12742 Bulk Product f786bf07 Books $368.92 233 1.6 64 BULK-a6065cf7
12743 Bulk Product fa947222 Clothing $801.78 325 2.4 72 BULK-c256e9ea
12744 Bulk Product 29d0cfeb Electronics $444.52 308 2.6 45 BULK-af0e29ba
12745 Bulk Product b29224d6 Home & Garden $839.05 225 4.6 80 BULK-cc68ec85
12746 Bulk Product f748444b Books $825.93 75 2.0 77 BULK-bc453af2
12747 Bulk Product 423f41e0 Books $263.70 183 3.5 32 BULK-be149ba4
12748 Bulk Product 8fc0df76 Electronics $250.39 430 2.7 24 BULK-d29ad17c
12749 Bulk Product 27b4648d Toys & Games $552.83 207 0.8 92 BULK-38c4a17a
12750 Bulk Product 18a8ea43 Clothing $272.29 202 1.0 55 BULK-d86d8547
12751 Bulk Product 863296d8 Electronics $854.73 171 3.9 60 BULK-021a857c
12752 Bulk Product d11be6d9 Sports & Outdoors $74.96 450 3.7 28 BULK-789460b9
12753 Bulk Product b506788f Sports & Outdoors $201.80 153 3.6 93 BULK-f8b78186
12754 Bulk Product d20df01d Electronics $79.03 37 3.0 98 BULK-b1c30bf6
12755 Bulk Product ce314980 Electronics $174.08 177 1.1 95 BULK-74612c0a
12756 Bulk Product 582d8ce3 Home & Garden $837.94 52 2.1 1 BULK-386036c2
12757 Bulk Product 182d6967 Books $66.28 234 0.9 0 BULK-86122906
12758 Bulk Product 21fbe6fc Sports & Outdoors $252.13 374 2.1 61 BULK-36428a9a
12759 Bulk Product 2b94ad31 Books $763.07 385 0.1 33 BULK-00a9095c
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