Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

17 ms

Page Size

50

Current Page

72 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 72 Results Showing 3551 - 3600 of 24441

ID Name Category Price Stock Rating Reviews SKU
3986 Premium Automotive Product Max Automotive $555.69 348 1.3 43 SKU-003986
3987 Mega Electronics Product Special Edition Electronics $965.03 482 1.9 597 SKU-003987
3988 Ultra Automotive Product Advanced Automotive $63.41 187 4.0 150 SKU-003988
3989 Economy Health & Beauty Product XL Health & Beauty $922.33 180 2.8 272 SKU-003989
3990 Ultra Home & Garden Product Plus Home & Garden $580.79 10 1.5 237 SKU-003990
3991 Super Food & Grocery Product XL Food & Grocery $343.81 471 1.4 588 SKU-003991
3992 Super Automotive Product 2024 Automotive $933.28 238 2.1 704 SKU-003992
3993 Ultra Health & Beauty Product Special Edition Health & Beauty $149.34 375 4.5 34 SKU-003993
3994 Elite Home & Garden Product Max Home & Garden $733.19 335 2.6 657 SKU-003994
3995 Super Electronics Product Advanced Electronics $963.99 416 3.8 428 SKU-003995
3996 Premium Toys & Games Product Classic Toys & Games $52.58 19 4.9 524 SKU-003996
3997 Professional Automotive Product 2024 Automotive $249.42 15 3.5 236 SKU-003997
4000 Ultra Sports & Outdoors Product 2024 Sports & Outdoors $471.16 71 4.0 963 SKU-004000
4001 Elite Health & Beauty Product Special Edition Health & Beauty $167.98 222 3.5 423 SKU-004001
4003 Super Home & Garden Product Advanced Home & Garden $739.74 56 1.3 448 SKU-004003
4004 Ultra Food & Grocery Product XL Food & Grocery $924.59 354 1.9 671 SKU-004004
4005 Pro Home & Garden Product XL Home & Garden $278.87 84 5.0 74 SKU-004005
4006 Mega Home & Garden Product Special Edition Home & Garden $793.73 102 3.9 903 SKU-004006
4007 Mega Food & Grocery Product XL Food & Grocery $435.27 183 3.7 888 SKU-004007
4008 Economy Clothing Product 2024 Clothing $571.51 164 4.1 742 SKU-004008
4009 Mega Clothing Product Special Edition Clothing $750.28 36 4.4 581 SKU-004009
4010 Mega Automotive Product Lite Automotive $820.89 346 3.2 286 SKU-004010
4011 Deluxe Sports & Outdoors Product Lite Sports & Outdoors $673.67 131 5.0 898 SKU-004011
4012 Elite Home & Garden Product Mini Home & Garden $775.05 299 3.6 377 SKU-004012
4013 Standard Office Supplies Product Lite Office Supplies $619.22 327 4.5 628 SKU-004013
4014 Pro Books Product Mini Books $273.61 110 2.2 521 SKU-004014
4015 Deluxe Sports & Outdoors Product XL Sports & Outdoors $575.23 476 4.6 174 SKU-004015
4016 Super Clothing Product 2024 Clothing $549.42 209 4.4 529 SKU-004016
4017 Deluxe Health & Beauty Product Advanced Health & Beauty $211.81 347 4.5 243 SKU-004017
4019 Deluxe Books Product Lite Books $505.20 258 4.6 65 SKU-004019
4020 Standard Books Product Pro Books $13.80 180 4.6 489 SKU-004020
4022 Elite Health & Beauty Product Pro Health & Beauty $164.78 92 1.7 736 SKU-004022
4023 Pro Food & Grocery Product Advanced Food & Grocery $198.16 31 2.0 355 SKU-004023
4026 Premium Sports & Outdoors Product Lite Sports & Outdoors $730.41 106 1.4 19 SKU-004026
4027 Elite Health & Beauty Product Classic Health & Beauty $451.00 290 2.9 566 SKU-004027
4028 Professional Sports & Outdoors Product Classic Sports & Outdoors $697.85 460 1.0 797 SKU-004028
4029 Deluxe Electronics Product Advanced Electronics $710.43 373 2.1 383 SKU-004029
4030 Ultra Electronics Product Special Edition Electronics $386.72 197 4.8 242 SKU-004030
4031 Super Sports & Outdoors Product Max Sports & Outdoors $910.48 135 3.8 75 SKU-004031
4032 Mega Office Supplies Product XL Office Supplies $275.23 442 2.9 871 SKU-004032
4033 Professional Office Supplies Product Pro Office Supplies $537.70 470 2.9 492 SKU-004033
4035 Deluxe Clothing Product Classic Clothing $849.42 111 1.2 991 SKU-004035
4036 Standard Automotive Product Advanced Automotive $361.22 77 3.2 140 SKU-004036
4037 Premium Toys & Games Product Special Edition Toys & Games $794.69 152 1.8 349 SKU-004037
4038 Elite Toys & Games Product Mini Toys & Games $697.75 23 1.5 107 SKU-004038
4040 Super Sports & Outdoors Product Special Edition Sports & Outdoors $916.79 226 2.4 731 SKU-004040
4042 Deluxe Office Supplies Product Pro Office Supplies $963.86 211 4.2 541 SKU-004042
4043 Super Sports & Outdoors Product XL Sports & Outdoors $589.65 427 1.7 369 SKU-004043
4045 Deluxe Office Supplies Product Advanced Office Supplies $472.85 211 2.0 425 SKU-004045
4046 Elite Clothing Product Pro Clothing $428.98 41 3.1 908 SKU-004046
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