Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

24 ms

Page Size

50

Current Page

38 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 38 Results Showing 1851 - 1900 of 24441

ID Name Category Price Stock Rating Reviews SKU
2090 Super Office Supplies Product Advanced Office Supplies $525.08 180 3.1 901 SKU-002090
2091 Deluxe Books Product Classic Books $67.30 84 2.9 476 SKU-002091
2092 Mega Clothing Product Advanced Clothing $552.05 109 1.8 89 SKU-002092
2094 Economy Electronics Product Pro Electronics $453.80 31 3.7 276 SKU-002094
2095 Premium Clothing Product Special Edition Clothing $515.76 412 2.1 838 SKU-002095
2096 Standard Clothing Product Classic Clothing $425.42 268 1.6 173 SKU-002096
2097 Economy Automotive Product Mini Automotive $215.07 224 2.9 582 SKU-002097
2098 Deluxe Health & Beauty Product Max Health & Beauty $691.99 327 2.7 220 SKU-002098
2100 Super Books Product Lite Books $150.33 345 2.4 229 SKU-002100
2101 Ultra Toys & Games Product Lite Toys & Games $155.66 91 1.1 693 SKU-002101
2102 Deluxe Health & Beauty Product Plus Health & Beauty $735.12 332 1.8 474 SKU-002102
2103 Pro Office Supplies Product Advanced Office Supplies $481.73 463 2.4 585 SKU-002103
2104 Deluxe Clothing Product Pro Clothing $245.71 365 1.6 663 SKU-002104
2105 Pro Books Product Max Books $70.07 144 1.6 282 SKU-002105
2106 Super Office Supplies Product Advanced Office Supplies $428.15 208 1.9 975 SKU-002106
2107 Elite Office Supplies Product Plus Office Supplies $910.23 269 1.3 632 SKU-002107
2108 Economy Health & Beauty Product XL Health & Beauty $350.27 244 4.7 462 SKU-002108
2109 Professional Office Supplies Product Max Office Supplies $155.23 219 3.3 465 SKU-002109
2110 Super Health & Beauty Product Special Edition Health & Beauty $242.83 359 3.6 712 SKU-002110
2111 Deluxe Automotive Product Special Edition Automotive $952.61 294 1.2 615 SKU-002111
2112 Professional Office Supplies Product Max Office Supplies $73.01 433 5.0 955 SKU-002112
2113 Pro Automotive Product Plus Automotive $156.48 497 4.8 272 SKU-002113
2114 Pro Home & Garden Product Pro Home & Garden $949.87 83 4.3 486 SKU-002114
2116 Pro Clothing Product Mini Clothing $789.87 57 3.0 209 SKU-002116
2117 Premium Home & Garden Product Special Edition Home & Garden $324.69 346 2.2 880 SKU-002117
2118 Economy Sports & Outdoors Product Plus Sports & Outdoors $350.03 423 5.0 871 SKU-002118
2119 Elite Sports & Outdoors Product Special Edition Sports & Outdoors $211.93 73 1.9 670 SKU-002119
2120 Economy Toys & Games Product Max Toys & Games $47.68 34 1.6 426 SKU-002120
2121 Deluxe Toys & Games Product Lite Toys & Games $196.78 21 3.5 789 SKU-002121
2122 Premium Home & Garden Product Special Edition Home & Garden $405.14 377 3.8 367 SKU-002122
2123 Deluxe Automotive Product 2024 Automotive $483.83 250 1.6 990 SKU-002123
2124 Economy Sports & Outdoors Product Advanced Sports & Outdoors $767.49 185 4.8 176 SKU-002124
2125 Ultra Toys & Games Product Lite Toys & Games $460.94 402 2.2 359 SKU-002125
2126 Ultra Automotive Product Mini Automotive $213.29 465 4.5 879 SKU-002126
2128 Elite Books Product Pro Books $871.64 279 2.0 344 SKU-002128
2129 Deluxe Electronics Product Lite Electronics $528.12 359 3.3 134 SKU-002129
2130 Super Food & Grocery Product Plus Food & Grocery $163.68 240 2.1 456 SKU-002130
2131 Standard Automotive Product Special Edition Automotive $921.28 27 1.0 963 SKU-002131
2132 Pro Books Product Pro Books $907.04 498 4.9 311 SKU-002132
2133 Economy Clothing Product Lite Clothing $423.25 382 2.7 294 SKU-002133
2134 Ultra Clothing Product 2024 Clothing $982.29 175 1.9 578 SKU-002134
2135 Ultra Clothing Product Max Clothing $714.21 3 4.4 867 SKU-002135
2136 Mega Electronics Product Lite Electronics $391.82 46 2.9 370 SKU-002136
2137 Deluxe Books Product Pro Books $417.71 232 3.0 480 SKU-002137
2138 Standard Sports & Outdoors Product Plus Sports & Outdoors $103.49 279 1.9 337 SKU-002138
2139 Pro Health & Beauty Product Max Health & Beauty $118.41 83 1.1 432 SKU-002139
2140 Premium Home & Garden Product Mini Home & Garden $520.57 251 2.0 124 SKU-002140
2141 Mega Home & Garden Product XL Home & Garden $325.86 107 3.9 156 SKU-002141
2142 Pro Home & Garden Product Classic Home & Garden $691.30 80 3.4 394 SKU-002142
2143 Premium Automotive Product Pro Automotive $777.81 78 1.8 997 SKU-002143
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