Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

26 ms

Page Size

50

Current Page

401 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 401 Results Showing 20001 - 20050 of 24441

ID Name Category Price Stock Rating Reviews SKU
20560 Bulk Product 8d4bd6e2 Clothing $80.51 447 0.4 65 BULK-65c8bafc
20561 Bulk Product 5804cbce Clothing $392.30 247 3.6 47 BULK-4af7fd0d
20562 Bulk Product 71fae38b Electronics $873.01 106 0.4 96 BULK-1ce73cf9
20563 Bulk Product 409e3181 Sports & Outdoors $405.50 389 0.6 49 BULK-dc2eb302
20564 Bulk Product 52a8d4f6 Home & Garden $115.66 126 4.0 33 BULK-1c5cfe29
20565 Bulk Product c193c779 Toys & Games $908.28 435 4.9 38 BULK-af5a651f
20566 Bulk Product 40f17e9c Clothing $70.88 281 2.9 30 BULK-2a46c82d
20567 Bulk Product 128551bc Electronics $54.40 305 0.2 14 BULK-ad64bd71
20568 Bulk Product 6631593e Sports & Outdoors $219.76 336 2.1 33 BULK-f5cfd747
20569 Bulk Product 834dd5ff Clothing $120.59 127 4.3 31 BULK-6d5eb73a
20570 Bulk Product 329f7bd4 Home & Garden $386.73 328 4.9 98 BULK-7fed6b0d
20571 Bulk Product 2e392d2b Sports & Outdoors $733.44 246 0.7 34 BULK-95130563
20572 Bulk Product ed229c7b Toys & Games $220.05 165 2.7 23 BULK-804ca855
20573 Bulk Product 406cebc5 Toys & Games $853.72 82 0.4 19 BULK-d9bc726c
20574 Bulk Product e454e17c Home & Garden $883.21 260 2.6 38 BULK-d367580d
20575 Bulk Product 657a46d1 Home & Garden $964.16 336 2.7 51 BULK-dfec22c3
20576 Bulk Product 038ea83b Electronics $11.44 245 1.6 81 BULK-92df9309
20577 Bulk Product a5492db6 Electronics $959.88 291 4.0 68 BULK-36a3d933
20578 Bulk Product 332a3a08 Clothing $797.26 376 3.3 96 BULK-2450c452
20579 Bulk Product 69f7d27a Sports & Outdoors $770.72 129 0.6 76 BULK-ff2af580
20580 Bulk Product 7b5d469a Books $55.56 197 3.3 29 BULK-ae07bcab
20581 Bulk Product c3eced66 Toys & Games $177.84 413 4.2 56 BULK-3a29f2af
20582 Bulk Product e505420d Home & Garden $550.57 181 0.7 33 BULK-d545a1a6
20583 Bulk Product 1754e6a6 Toys & Games $982.47 122 3.7 3 BULK-a4ea145a
20584 Bulk Product d44ce4d6 Toys & Games $163.07 321 1.9 10 BULK-d450510e
20585 Bulk Product e3e95bc3 Toys & Games $218.22 217 2.7 58 BULK-2ded9196
20586 Bulk Product 8c51e7ee Toys & Games $241.20 101 0.1 1 BULK-48725537
20587 Bulk Product c9e841e1 Sports & Outdoors $341.40 28 3.7 14 BULK-af229810
20588 Bulk Product 63cfc11c Sports & Outdoors $363.99 344 4.3 71 BULK-bd5acd11
20589 Bulk Product 06475de1 Sports & Outdoors $13.69 31 0.1 98 BULK-1031add3
20590 Bulk Product 474e66c8 Books $609.17 12 3.7 2 BULK-ef7c598e
20591 Bulk Product bd3ec1d4 Sports & Outdoors $461.96 144 2.0 88 BULK-86545ecc
20592 Bulk Product 321c8120 Clothing $963.84 435 3.7 89 BULK-439a5a7f
20593 Bulk Product 626fd571 Electronics $325.03 434 4.5 87 BULK-76ed57d5
20594 Bulk Product 6392cc79 Books $317.04 196 2.0 94 BULK-b99ad59e
20595 Bulk Product 5cb8b900 Electronics $810.52 162 1.2 17 BULK-d5949527
20596 Bulk Product 5795f06d Books $224.99 205 1.4 62 BULK-ee2fd1fa
20597 Bulk Product ea6c77f2 Home & Garden $345.24 212 1.6 20 BULK-165b56e2
20598 Bulk Product 0ca5d03c Sports & Outdoors $166.94 238 0.7 61 BULK-f151916f
20599 Bulk Product bdd6d031 Toys & Games $956.25 49 4.1 36 BULK-a822914c
20600 Bulk Product f9eba35a Books $586.26 182 0.1 57 BULK-d53af9c6
20601 Bulk Product d064a2de Home & Garden $245.84 496 1.1 96 BULK-7b579590
20602 Bulk Product 427202dc Home & Garden $338.91 342 4.1 1 BULK-a9865603
20603 Bulk Product 51626d77 Sports & Outdoors $839.15 79 0.5 31 BULK-b70b2a42
20604 Bulk Product 302b9ddc Sports & Outdoors $727.63 318 1.2 27 BULK-ecd69485
20605 Bulk Product 1bf62b22 Home & Garden $849.36 295 0.5 66 BULK-5d8512a0
20606 Bulk Product aa90bd18 Sports & Outdoors $709.98 143 0.8 18 BULK-890aa805
20607 Bulk Product 7dc796ad Home & Garden $211.48 166 1.7 32 BULK-0b4619b6
20608 Bulk Product 7f196b4f Books $633.71 326 0.0 91 BULK-c94aaedf
20609 Bulk Product 79d78cd2 Toys & Games $911.82 433 1.5 65 BULK-631bf3d3
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