Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

9 ms

Page Size

50

Current Page

51 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 51 Results Showing 2501 - 2550 of 24441

ID Name Category Price Stock Rating Reviews SKU
2807 Deluxe Office Supplies Product Mini Office Supplies $212.32 344 4.2 493 SKU-002807
2808 Economy Office Supplies Product Plus Office Supplies $802.97 111 3.0 703 SKU-002808
2810 Economy Books Product Mini Books $130.14 159 1.5 550 SKU-002810
2812 Super Office Supplies Product Pro Office Supplies $616.40 261 1.5 270 SKU-002812
2813 Economy Clothing Product 2024 Clothing $471.16 496 4.3 55 SKU-002813
2814 Pro Toys & Games Product Plus Toys & Games $638.36 213 3.8 344 SKU-002814
2815 Standard Toys & Games Product XL Toys & Games $568.53 79 3.4 835 SKU-002815
2816 Mega Books Product Classic Books $529.66 478 2.5 54 SKU-002816
2817 Ultra Health & Beauty Product XL Health & Beauty $794.16 39 3.8 985 SKU-002817
2818 Professional Automotive Product XL Automotive $718.78 79 4.0 20 SKU-002818
2819 Super Electronics Product 2024 Electronics $450.00 383 1.8 696 SKU-002819
2820 Mega Home & Garden Product Pro Home & Garden $404.15 434 1.6 768 SKU-002820
2821 Ultra Health & Beauty Product Plus Health & Beauty $442.91 52 2.1 294 SKU-002821
2822 Premium Office Supplies Product Classic Office Supplies $97.27 230 2.0 52 SKU-002822
2823 Premium Office Supplies Product Plus Office Supplies $474.72 373 3.7 208 SKU-002823
2824 Mega Sports & Outdoors Product Pro Sports & Outdoors $616.65 0 3.2 559 SKU-002824
2826 Professional Health & Beauty Product Plus Health & Beauty $74.48 460 3.0 521 SKU-002826
2827 Professional Toys & Games Product Special Edition Toys & Games $254.31 218 3.1 580 SKU-002827
2828 Professional Food & Grocery Product Plus Food & Grocery $789.72 75 3.0 425 SKU-002828
2830 Ultra Home & Garden Product Lite Home & Garden $541.82 378 1.5 753 SKU-002830
2831 Pro Home & Garden Product Advanced Home & Garden $714.95 349 1.8 34 SKU-002831
2832 Ultra Food & Grocery Product XL Food & Grocery $809.99 44 4.2 300 SKU-002832
2833 Ultra Toys & Games Product Pro Toys & Games $658.19 212 2.8 930 SKU-002833
2835 Mega Health & Beauty Product Max Health & Beauty $255.77 9 4.5 978 SKU-002835
2836 Elite Automotive Product Max Automotive $645.96 449 2.7 450 SKU-002836
2837 Elite Sports & Outdoors Product 2024 Sports & Outdoors $779.23 363 5.0 56 SKU-002837
2838 Economy Clothing Product Advanced Clothing $368.50 455 1.6 244 SKU-002838
2839 Ultra Toys & Games Product Pro Toys & Games $193.58 309 1.9 832 SKU-002839
2840 Economy Health & Beauty Product Advanced Health & Beauty $719.00 384 4.6 805 SKU-002840
2841 Professional Food & Grocery Product Advanced Food & Grocery $11.07 142 3.6 339 SKU-002841
2842 Mega Home & Garden Product Max Home & Garden $883.59 320 3.6 794 SKU-002842
2843 Professional Health & Beauty Product Lite Health & Beauty $715.33 462 1.4 569 SKU-002843
2844 Premium Food & Grocery Product Max Food & Grocery $905.60 388 1.2 907 SKU-002844
2845 Super Books Product Plus Books $13.99 354 4.4 211 SKU-002845
2846 Deluxe Electronics Product Plus Electronics $690.37 127 4.8 860 SKU-002846
2847 Professional Toys & Games Product Lite Toys & Games $621.74 264 3.1 25 SKU-002847
2848 Economy Clothing Product Advanced Clothing $318.31 412 3.5 267 SKU-002848
2849 Elite Automotive Product 2024 Automotive $470.39 398 2.5 184 SKU-002849
2850 Pro Toys & Games Product Pro Toys & Games $195.91 338 2.9 573 SKU-002850
2851 Ultra Automotive Product Plus Automotive $537.32 367 3.9 451 SKU-002851
2852 Deluxe Electronics Product Plus Electronics $804.00 468 2.3 275 SKU-002852
2853 Premium Sports & Outdoors Product 2024 Sports & Outdoors $319.84 34 4.1 111 SKU-002853
2854 Deluxe Home & Garden Product Plus Home & Garden $688.93 385 1.1 978 SKU-002854
2856 Pro Health & Beauty Product XL Health & Beauty $201.92 384 2.4 807 SKU-002856
2857 Ultra Electronics Product Special Edition Electronics $272.53 321 2.2 428 SKU-002857
2858 Economy Electronics Product Lite Electronics $121.71 49 1.8 763 SKU-002858
2859 Deluxe Toys & Games Product Special Edition Toys & Games $442.24 59 2.7 685 SKU-002859
2860 Standard Toys & Games Product 2024 Toys & Games $969.10 369 2.3 638 SKU-002860
2861 Professional Electronics Product Plus Electronics $694.82 392 4.4 948 SKU-002861
2862 Economy Home & Garden Product Plus Home & Garden $432.78 377 3.6 146 SKU-002862
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