Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

15 ms

Page Size

50

Current Page

54 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 54 Results Showing 2651 - 2700 of 24441

ID Name Category Price Stock Rating Reviews SKU
2970 Mega Electronics Product Mini Electronics $92.62 78 4.6 456 SKU-002970
2971 Deluxe Books Product Classic Books $561.44 164 3.8 573 SKU-002971
2972 Super Food & Grocery Product Pro Food & Grocery $704.51 189 1.9 247 SKU-002972
2973 Economy Clothing Product Mini Clothing $710.09 116 5.0 36 SKU-002973
2974 Pro Health & Beauty Product 2024 Health & Beauty $758.52 144 5.0 420 SKU-002974
2975 Ultra Automotive Product Plus Automotive $738.88 262 4.0 6 SKU-002975
2976 Deluxe Health & Beauty Product XL Health & Beauty $170.83 314 4.1 157 SKU-002976
2977 Mega Office Supplies Product XL Office Supplies $532.41 218 2.3 10 SKU-002977
2978 Mega Office Supplies Product Classic Office Supplies $176.89 198 3.9 67 SKU-002978
2979 Economy Sports & Outdoors Product Advanced Sports & Outdoors $229.11 200 1.9 710 SKU-002979
2980 Ultra Home & Garden Product Special Edition Home & Garden $436.06 0 2.7 286 SKU-002980
2981 Professional Health & Beauty Product Mini Health & Beauty $733.90 291 4.8 497 SKU-002981
2982 Ultra Food & Grocery Product 2024 Food & Grocery $459.52 402 3.3 931 SKU-002982
2983 Deluxe Sports & Outdoors Product Plus Sports & Outdoors $453.07 125 1.2 444 SKU-002983
2984 Deluxe Health & Beauty Product Plus Health & Beauty $360.97 86 1.8 712 SKU-002984
2985 Ultra Clothing Product Max Clothing $869.57 469 2.1 525 SKU-002985
2986 Standard Food & Grocery Product Classic Food & Grocery $932.77 249 4.6 655 SKU-002986
2987 Deluxe Food & Grocery Product Max Food & Grocery $237.66 125 1.7 464 SKU-002987
2988 Standard Toys & Games Product Pro Toys & Games $633.37 80 1.0 573 SKU-002988
2989 Mega Clothing Product Pro Clothing $243.11 463 3.2 225 SKU-002989
2991 Standard Books Product Pro Books $761.52 447 1.7 146 SKU-002991
2992 Professional Office Supplies Product 2024 Office Supplies $95.42 48 1.4 286 SKU-002992
2993 Mega Health & Beauty Product Pro Health & Beauty $144.59 490 1.3 761 SKU-002993
2994 Elite Electronics Product XL Electronics $491.78 477 2.2 443 SKU-002994
2995 Super Health & Beauty Product Plus Health & Beauty $580.75 199 4.2 248 SKU-002995
2996 Super Sports & Outdoors Product XL Sports & Outdoors $249.91 87 1.3 485 SKU-002996
2997 Ultra Books Product Special Edition Books $93.94 493 1.1 597 SKU-002997
2998 Pro Books Product Mini Books $423.89 113 2.8 997 SKU-002998
2999 Deluxe Office Supplies Product Lite Office Supplies $549.70 148 4.2 615 SKU-002999
3001 Mega Automotive Product Classic Automotive $926.92 242 2.1 50 SKU-003001
3002 Mega Clothing Product Pro Clothing $38.85 349 4.4 623 SKU-003002
3004 Standard Toys & Games Product Mini Toys & Games $678.00 450 2.6 546 SKU-003004
3005 Standard Food & Grocery Product Pro Food & Grocery $535.87 235 2.2 126 SKU-003005
3006 Economy Food & Grocery Product XL Food & Grocery $754.99 88 3.4 428 SKU-003006
3007 Pro Automotive Product 2024 Automotive $570.60 301 4.1 92 SKU-003007
3009 Standard Books Product Mini Books $814.22 435 2.6 644 SKU-003009
3010 Standard Health & Beauty Product 2024 Health & Beauty $132.47 499 3.6 745 SKU-003010
3011 Premium Food & Grocery Product Pro Food & Grocery $676.35 181 1.1 953 SKU-003011
3012 Economy Toys & Games Product XL Toys & Games $626.10 296 1.2 405 SKU-003012
3013 Ultra Clothing Product Classic Clothing $43.85 140 1.1 230 SKU-003013
3014 Deluxe Electronics Product Pro Electronics $697.71 12 2.0 79 SKU-003014
3015 Ultra Home & Garden Product Mini Home & Garden $109.25 24 2.1 660 SKU-003015
3016 Elite Home & Garden Product Plus Home & Garden $681.68 376 4.8 286 SKU-003016
3017 Standard Toys & Games Product Pro Toys & Games $621.22 43 1.9 359 SKU-003017
3018 Mega Health & Beauty Product Plus Health & Beauty $931.58 222 3.0 53 SKU-003018
3019 Pro Books Product Special Edition Books $689.67 231 2.0 183 SKU-003019
3021 Professional Food & Grocery Product Plus Food & Grocery $978.51 328 4.9 257 SKU-003021
3022 Elite Home & Garden Product Mini Home & Garden $262.16 275 4.3 699 SKU-003022
3023 Deluxe Office Supplies Product Plus Office Supplies $613.74 27 2.7 610 SKU-003023
3024 Premium Toys & Games Product Special Edition Toys & Games $423.43 136 1.9 738 SKU-003024
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