Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

9 ms

Page Size

50

Current Page

65 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 65 Results Showing 3201 - 3250 of 24441

ID Name Category Price Stock Rating Reviews SKU
3596 Mega Office Supplies Product Mini Office Supplies $670.22 356 1.2 919 SKU-003596
3597 Elite Health & Beauty Product Pro Health & Beauty $198.69 32 3.3 375 SKU-003597
3598 Standard Office Supplies Product Mini Office Supplies $317.02 13 4.3 622 SKU-003598
3599 Pro Books Product Lite Books $230.88 20 2.3 958 SKU-003599
3600 Super Office Supplies Product Pro Office Supplies $191.71 448 3.0 515 SKU-003600
3601 Premium Sports & Outdoors Product Advanced Sports & Outdoors $405.55 109 2.0 214 SKU-003601
3602 Premium Automotive Product Mini Automotive $320.01 468 4.4 638 SKU-003602
3603 Super Toys & Games Product Special Edition Toys & Games $272.73 295 3.0 911 SKU-003603
3604 Pro Health & Beauty Product Plus Health & Beauty $337.23 477 1.2 675 SKU-003604
3605 Standard Clothing Product Lite Clothing $978.04 398 1.8 94 SKU-003605
3606 Economy Sports & Outdoors Product Plus Sports & Outdoors $193.88 139 3.9 871 SKU-003606
3607 Premium Home & Garden Product Pro Home & Garden $561.06 313 4.5 422 SKU-003607
3608 Super Home & Garden Product Mini Home & Garden $20.23 276 4.7 498 SKU-003608
3609 Premium Automotive Product Mini Automotive $860.49 258 1.7 690 SKU-003609
3610 Elite Health & Beauty Product Max Health & Beauty $426.21 444 2.9 321 SKU-003610
3611 Elite Office Supplies Product XL Office Supplies $759.27 292 5.0 602 SKU-003611
3612 Elite Books Product Mini Books $588.49 438 1.3 775 SKU-003612
3613 Deluxe Electronics Product Plus Electronics $536.65 448 3.5 843 SKU-003613
3614 Mega Sports & Outdoors Product Special Edition Sports & Outdoors $200.05 374 4.1 25 SKU-003614
3615 Pro Food & Grocery Product 2024 Food & Grocery $69.12 49 1.1 531 SKU-003615
3616 Mega Automotive Product Max Automotive $753.04 463 2.5 967 SKU-003616
3617 Ultra Health & Beauty Product 2024 Health & Beauty $666.98 168 1.3 177 SKU-003617
3618 Standard Clothing Product Plus Clothing $846.89 196 4.1 262 SKU-003618
3619 Deluxe Sports & Outdoors Product Pro Sports & Outdoors $698.23 92 2.0 842 SKU-003619
3620 Professional Sports & Outdoors Product Lite Sports & Outdoors $593.11 180 3.9 611 SKU-003620
3621 Elite Clothing Product Classic Clothing $121.51 298 1.2 161 SKU-003621
3622 Professional Automotive Product Advanced Automotive $479.30 408 3.9 922 SKU-003622
3623 Elite Health & Beauty Product Lite Health & Beauty $728.11 42 3.1 424 SKU-003623
3624 Professional Toys & Games Product XL Toys & Games $647.25 236 2.9 949 SKU-003624
3625 Deluxe Toys & Games Product Lite Toys & Games $953.88 465 2.1 937 SKU-003625
3626 Pro Office Supplies Product Lite Office Supplies $738.73 293 2.6 879 SKU-003626
3628 Ultra Toys & Games Product Max Toys & Games $986.10 348 4.5 437 SKU-003628
3630 Ultra Home & Garden Product 2024 Home & Garden $980.75 24 3.4 169 SKU-003630
3631 Mega Office Supplies Product 2024 Office Supplies $293.47 446 3.6 777 SKU-003631
3632 Elite Toys & Games Product Plus Toys & Games $308.22 44 2.8 328 SKU-003632
3633 Super Sports & Outdoors Product Lite Sports & Outdoors $852.37 378 3.6 394 SKU-003633
3634 Standard Home & Garden Product 2024 Home & Garden $351.75 452 1.4 71 SKU-003634
3635 Deluxe Food & Grocery Product Advanced Food & Grocery $409.68 70 1.6 843 SKU-003635
3636 Economy Clothing Product Plus Clothing $535.80 286 3.6 880 SKU-003636
3638 Professional Food & Grocery Product Classic Food & Grocery $949.35 122 2.3 449 SKU-003638
3639 Elite Sports & Outdoors Product Special Edition Sports & Outdoors $842.93 350 4.4 504 SKU-003639
3640 Standard Sports & Outdoors Product Pro Sports & Outdoors $480.87 427 4.0 225 SKU-003640
3641 Elite Food & Grocery Product Advanced Food & Grocery $725.76 410 2.0 519 SKU-003641
3642 Pro Office Supplies Product Pro Office Supplies $486.18 372 2.7 437 SKU-003642
3643 Deluxe Health & Beauty Product Lite Health & Beauty $611.39 360 4.2 662 SKU-003643
3644 Professional Books Product Classic Books $336.28 210 4.2 407 SKU-003644
3645 Elite Electronics Product Lite Electronics $748.50 389 1.3 215 SKU-003645
3646 Elite Clothing Product Plus Clothing $375.39 488 2.2 583 SKU-003646
3647 Standard Books Product Plus Books $20.64 19 3.0 109 SKU-003647
3650 Elite Food & Grocery Product 2024 Food & Grocery $717.76 154 1.5 687 SKU-003650
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