Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

80 ms

Page Size

25

Current Page

92 / 978

Total Records

24441

Items per page: 25 50 100 200

Page 92 Results Showing 2276 - 2300 of 24441

ID Name Category Price Stock Rating Reviews SKU
2558 Premium Health & Beauty Product Classic Health & Beauty $613.28 326 2.9 673 SKU-002558
2559 Ultra Home & Garden Product Plus Home & Garden $79.97 183 1.7 141 SKU-002559
2560 Pro Food & Grocery Product 2024 Food & Grocery $833.81 336 2.0 450 SKU-002560
2561 Professional Toys & Games Product Special Edition Toys & Games $459.41 104 1.6 976 SKU-002561
2562 Professional Sports & Outdoors Product XL Sports & Outdoors $367.09 105 4.8 335 SKU-002562
2563 Premium Home & Garden Product Lite Home & Garden $340.36 275 3.1 748 SKU-002563
2564 Elite Books Product 2024 Books $641.36 422 2.1 691 SKU-002564
2565 Economy Sports & Outdoors Product XL Sports & Outdoors $165.43 457 1.6 562 SKU-002565
2566 Ultra Food & Grocery Product Pro Food & Grocery $635.83 266 3.9 243 SKU-002566
2567 Deluxe Automotive Product XL Automotive $436.72 361 4.2 591 SKU-002567
2568 Professional Automotive Product Advanced Automotive $169.78 36 2.8 869 SKU-002568
2569 Deluxe Clothing Product 2024 Clothing $315.20 463 4.6 864 SKU-002569
2570 Pro Home & Garden Product Advanced Home & Garden $381.93 312 4.4 183 SKU-002570
2571 Pro Health & Beauty Product 2024 Health & Beauty $145.09 43 4.9 869 SKU-002571
2572 Deluxe Clothing Product Lite Clothing $485.28 181 4.0 690 SKU-002572
2573 Economy Office Supplies Product Max Office Supplies $24.64 141 3.9 34 SKU-002573
2574 Ultra Automotive Product Plus Automotive $779.56 246 1.3 321 SKU-002574
2575 Ultra Toys & Games Product Advanced Toys & Games $805.52 120 1.6 523 SKU-002575
2576 Economy Clothing Product Advanced Clothing $554.26 53 3.0 431 SKU-002576
2577 Ultra Automotive Product Pro Automotive $825.09 325 3.1 736 SKU-002577
2578 Ultra Clothing Product Plus Clothing $787.26 156 4.6 545 SKU-002578
2579 Mega Toys & Games Product 2024 Toys & Games $289.54 169 4.5 790 SKU-002579
2581 Mega Home & Garden Product Mini Home & Garden $53.61 160 2.0 928 SKU-002581
2583 Deluxe Food & Grocery Product Special Edition Food & Grocery $923.36 432 2.8 143 SKU-002583
2584 Economy Food & Grocery Product Advanced Food & Grocery $159.69 161 4.2 445 SKU-002584
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