Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

9 ms

Page Size

50

Current Page

76 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 76 Results Showing 3751 - 3800 of 24441

ID Name Category Price Stock Rating Reviews SKU
4220 Mega Sports & Outdoors Product Max Sports & Outdoors $198.09 465 3.4 245 SKU-004220
4221 Elite Home & Garden Product 2024 Home & Garden $587.33 313 3.0 680 SKU-004221
4222 Super Office Supplies Product Lite Office Supplies $150.53 195 1.3 848 SKU-004222
4223 Professional Toys & Games Product Lite Toys & Games $797.00 318 4.4 571 SKU-004223
4224 Pro Clothing Product Advanced Clothing $223.50 497 4.6 414 SKU-004224
4225 Economy Food & Grocery Product Max Food & Grocery $697.29 393 2.4 454 SKU-004225
4226 Professional Sports & Outdoors Product Advanced Sports & Outdoors $398.68 494 1.9 651 SKU-004226
4227 Ultra Automotive Product 2024 Automotive $282.98 343 4.2 590 SKU-004227
4228 Deluxe Food & Grocery Product Advanced Food & Grocery $42.31 335 3.1 430 SKU-004228
4229 Economy Home & Garden Product 2024 Home & Garden $863.10 492 1.7 170 SKU-004229
4231 Standard Automotive Product Pro Automotive $62.44 42 5.0 365 SKU-004231
4232 Deluxe Electronics Product Lite Electronics $201.06 470 1.4 597 SKU-004232
4233 Deluxe Food & Grocery Product Max Food & Grocery $483.17 127 4.7 263 SKU-004233
4234 Premium Clothing Product Mini Clothing $370.11 130 2.7 725 SKU-004234
4235 Pro Toys & Games Product Special Edition Toys & Games $898.49 181 4.3 282 SKU-004235
4237 Economy Home & Garden Product Mini Home & Garden $558.05 349 1.0 902 SKU-004237
4238 Pro Home & Garden Product Lite Home & Garden $183.12 335 1.0 493 SKU-004238
4239 Mega Office Supplies Product Advanced Office Supplies $342.15 68 4.3 571 SKU-004239
4240 Ultra Automotive Product Plus Automotive $962.98 359 4.2 438 SKU-004240
4241 Mega Automotive Product Mini Automotive $919.39 396 3.7 457 SKU-004241
4242 Elite Office Supplies Product 2024 Office Supplies $83.86 68 4.4 529 SKU-004242
4243 Elite Books Product XL Books $303.44 327 2.8 473 SKU-004243
4244 Pro Automotive Product Special Edition Automotive $727.81 122 2.6 916 SKU-004244
4245 Premium Toys & Games Product Max Toys & Games $44.76 161 1.5 216 SKU-004245
4246 Premium Health & Beauty Product Pro Health & Beauty $190.79 482 4.4 542 SKU-004246
4247 Super Food & Grocery Product XL Food & Grocery $618.60 288 1.4 821 SKU-004247
4248 Economy Electronics Product XL Electronics $354.68 244 2.0 418 SKU-004248
4249 Ultra Books Product Plus Books $987.64 95 2.5 42 SKU-004249
4250 Pro Health & Beauty Product Plus Health & Beauty $643.28 178 2.2 719 SKU-004250
4251 Deluxe Health & Beauty Product Mini Health & Beauty $176.20 451 4.8 167 SKU-004251
4252 Deluxe Office Supplies Product 2024 Office Supplies $922.39 319 3.1 370 SKU-004252
4253 Standard Toys & Games Product Lite Toys & Games $537.40 379 2.4 321 SKU-004253
4254 Elite Books Product XL Books $565.89 379 4.0 677 SKU-004254
4255 Super Clothing Product 2024 Clothing $632.02 74 2.1 719 SKU-004255
4257 Premium Sports & Outdoors Product Special Edition Sports & Outdoors $747.32 354 3.5 631 SKU-004257
4258 Standard Health & Beauty Product Max Health & Beauty $148.08 195 4.3 674 SKU-004258
4259 Ultra Electronics Product Mini Electronics $456.35 166 4.0 500 SKU-004259
4260 Ultra Electronics Product Lite Electronics $213.26 484 2.8 963 SKU-004260
4261 Elite Toys & Games Product Advanced Toys & Games $321.08 377 1.3 979 SKU-004261
4262 Super Electronics Product XL Electronics $317.26 49 2.8 702 SKU-004262
4263 Ultra Health & Beauty Product Lite Health & Beauty $783.75 338 2.5 915 SKU-004263
4264 Standard Books Product Classic Books $161.16 3 2.6 729 SKU-004264
4265 Ultra Electronics Product Mini Electronics $888.78 151 1.7 217 SKU-004265
4266 Pro Toys & Games Product Lite Toys & Games $230.69 482 1.1 354 SKU-004266
4267 Mega Office Supplies Product Plus Office Supplies $438.55 206 1.4 187 SKU-004267
4268 Professional Health & Beauty Product Lite Health & Beauty $252.20 7 1.3 802 SKU-004268
4269 Premium Books Product Mini Books $508.38 374 2.5 464 SKU-004269
4270 Mega Clothing Product Classic Clothing $810.57 416 3.4 610 SKU-004270
4271 Professional Sports & Outdoors Product Advanced Sports & Outdoors $143.12 404 3.9 926 SKU-004271
4272 Deluxe Office Supplies Product Pro Office Supplies $810.92 113 2.6 893 SKU-004272
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