Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

25 ms

Page Size

50

Current Page

361 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 361 Results Showing 18001 - 18050 of 24441

ID Name Category Price Stock Rating Reviews SKU
18560 Bulk Product 3e98297e Clothing $781.80 284 0.2 16 BULK-8fa158cb
18561 Bulk Product 6bb128ea Toys & Games $591.47 428 4.9 38 BULK-f52cbe50
18562 Bulk Product bc9a26d6 Clothing $628.08 303 4.3 9 BULK-bc93a451
18563 Bulk Product bc651dba Sports & Outdoors $954.74 54 1.9 73 BULK-39f078ee
18564 Bulk Product 25482623 Books $755.17 274 3.9 11 BULK-92f45482
18565 Bulk Product 74f1f7e3 Toys & Games $708.52 462 3.8 34 BULK-bcb502fd
18566 Bulk Product a1fdbbf6 Electronics $258.76 60 0.8 63 BULK-7eccb82c
18567 Bulk Product 739d60f4 Electronics $706.21 270 0.7 48 BULK-98186ace
18568 Bulk Product 0219bc78 Clothing $825.20 249 3.8 11 BULK-ff37b861
18569 Bulk Product 6b33af50 Clothing $648.59 214 2.0 83 BULK-0f04ea86
18570 Bulk Product 57ea12b8 Home & Garden $798.13 134 4.8 51 BULK-abc90162
18571 Bulk Product a632c82c Books $386.34 370 3.0 21 BULK-0a0b71fc
18572 Bulk Product 06dcfcdd Books $270.25 380 1.5 28 BULK-6e5484b9
18573 Bulk Product e9f24998 Clothing $142.57 249 4.2 11 BULK-cf2551b3
18574 Bulk Product 5bd6caf2 Home & Garden $649.57 67 0.2 35 BULK-c80e2eb8
18575 Bulk Product 54f801ec Clothing $659.45 344 4.0 33 BULK-31e66cba
18576 Bulk Product 131080af Toys & Games $418.59 144 4.0 61 BULK-4c10571c
18577 Bulk Product 957301e9 Home & Garden $841.22 24 2.7 0 BULK-6975eca2
18578 Bulk Product f27d3236 Sports & Outdoors $486.74 386 0.3 7 BULK-14c9c678
18579 Bulk Product 42b9829c Home & Garden $739.45 71 1.5 58 BULK-461b9b94
18580 Bulk Product 6676a1a2 Clothing $241.72 196 1.5 98 BULK-7f30a4da
18581 Bulk Product 9fcd7159 Toys & Games $128.92 192 4.9 32 BULK-be57e39c
18582 Bulk Product c711de3f Electronics $579.78 313 0.9 3 BULK-e5f8f2b4
18583 Bulk Product db537671 Electronics $433.62 276 0.1 95 BULK-2ccc5a1c
18584 Bulk Product 1c2d2acb Clothing $426.72 17 1.8 45 BULK-24be0cd9
18585 Bulk Product 13853a38 Sports & Outdoors $228.29 335 0.5 11 BULK-c4a7a62d
18586 Bulk Product 9aac975a Toys & Games $196.54 373 3.0 49 BULK-0d97e82c
18587 Bulk Product 582d74b3 Home & Garden $490.42 426 0.2 69 BULK-0c27cefe
18588 Bulk Product 68645b96 Clothing $987.48 461 4.5 41 BULK-a7fd55a9
18589 Bulk Product 0d48e45b Clothing $22.38 299 3.4 59 BULK-7b95be12
18590 Bulk Product 3ed0b5d9 Sports & Outdoors $902.49 316 0.6 24 BULK-8e426d84
18591 Bulk Product a7bdf98a Electronics $457.22 207 4.1 71 BULK-69d8b421
18592 Bulk Product 529a827c Home & Garden $855.22 41 4.1 57 BULK-d55c3874
18593 Bulk Product dd5dbc5b Books $939.95 378 1.9 82 BULK-3e70744e
18594 Bulk Product cde1ed9c Clothing $552.74 293 0.9 95 BULK-8710e649
18595 Bulk Product 8027f7f3 Sports & Outdoors $412.11 413 1.3 75 BULK-1659e932
18596 Bulk Product 03c4b151 Clothing $480.57 207 1.4 26 BULK-f1470f16
18597 Bulk Product c4482a93 Clothing $352.50 354 1.7 70 BULK-0ec55919
18598 Bulk Product 9fbc898b Sports & Outdoors $971.95 335 2.8 82 BULK-cc54b158
18599 Bulk Product 3674edab Home & Garden $135.46 480 5.0 1 BULK-9f1f0e76
18600 Bulk Product 9115ae68 Home & Garden $508.12 450 1.0 78 BULK-5b2ba22a
18601 Bulk Product 4c9101c3 Home & Garden $706.10 85 0.8 0 BULK-92e726e3
18602 Bulk Product 28d04f26 Electronics $314.82 33 4.4 0 BULK-2051efd0
18603 Bulk Product c7d176b0 Home & Garden $768.97 124 2.4 69 BULK-32293106
18604 Bulk Product f69ccf44 Sports & Outdoors $164.69 185 3.9 96 BULK-baac7b7e
18605 Bulk Product b5fdecee Electronics $705.39 256 3.4 70 BULK-6bfe1d22
18606 Bulk Product ba13113b Clothing $744.20 364 1.6 22 BULK-8d541936
18607 Bulk Product 0f07cd99 Electronics $799.92 291 5.0 77 BULK-c192d1d5
18608 Bulk Product ed97d789 Home & Garden $613.35 174 0.0 98 BULK-69649b4b
18609 Bulk Product 80df26ef Electronics $255.76 189 2.9 65 BULK-5b8296c8
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