Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

10 ms

Page Size

50

Current Page

9 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 9 Results Showing 401 - 450 of 24441

ID Name Category Price Stock Rating Reviews SKU
448 Pro Toys & Games Product Plus Toys & Games $953.86 485 1.4 585 SKU-000448
450 Ultra Clothing Product Classic Clothing $402.45 493 4.3 648 SKU-000450
451 Ultra Office Supplies Product Special Edition Office Supplies $20.75 170 3.7 952 SKU-000451
452 Professional Electronics Product Special Edition Electronics $645.14 171 1.7 300 SKU-000452
453 Mega Food & Grocery Product Max Food & Grocery $188.84 222 2.5 364 SKU-000453
455 Super Toys & Games Product Classic Toys & Games $521.92 88 2.5 100 SKU-000455
457 Mega Home & Garden Product Plus Home & Garden $172.98 105 2.2 844 SKU-000457
458 Standard Home & Garden Product Mini Home & Garden $233.01 456 1.1 265 SKU-000458
459 Mega Toys & Games Product Special Edition Toys & Games $470.70 226 3.9 343 SKU-000459
460 Ultra Sports & Outdoors Product Pro Sports & Outdoors $852.07 331 3.9 659 SKU-000460
461 Pro Automotive Product Special Edition Automotive $907.92 200 4.5 936 SKU-000461
462 Mega Health & Beauty Product Classic Health & Beauty $596.82 473 3.1 996 SKU-000462
463 Elite Home & Garden Product Plus Home & Garden $383.00 421 3.2 106 SKU-000463
464 Mega Health & Beauty Product Mini Health & Beauty $539.16 24 3.8 919 SKU-000464
465 Premium Clothing Product Pro Clothing $45.09 109 2.1 358 SKU-000465
466 Ultra Office Supplies Product Plus Office Supplies $433.00 411 3.2 388 SKU-000466
467 Elite Clothing Product Plus Clothing $782.17 69 4.2 787 SKU-000467
468 Economy Clothing Product Advanced Clothing $373.03 415 4.1 323 SKU-000468
469 Mega Automotive Product Max Automotive $236.74 322 2.2 628 SKU-000469
470 Super Sports & Outdoors Product Max Sports & Outdoors $511.10 335 2.8 171 SKU-000470
471 Standard Clothing Product Lite Clothing $233.46 309 4.1 447 SKU-000471
472 Super Home & Garden Product Classic Home & Garden $297.59 345 3.3 168 SKU-000472
473 Ultra Automotive Product XL Automotive $84.95 67 4.2 388 SKU-000473
475 Mega Books Product Classic Books $917.04 425 1.9 395 SKU-000475
476 Professional Clothing Product Lite Clothing $614.20 376 3.1 266 SKU-000476
477 Deluxe Home & Garden Product XL Home & Garden $484.71 160 4.9 30 SKU-000477
478 Ultra Sports & Outdoors Product Special Edition Sports & Outdoors $733.98 383 2.1 150 SKU-000478
479 Ultra Clothing Product Special Edition Clothing $389.33 186 3.6 232 SKU-000479
480 Premium Toys & Games Product Advanced Toys & Games $102.55 390 4.0 182 SKU-000480
481 Pro Automotive Product Mini Automotive $969.07 497 2.4 293 SKU-000481
482 Mega Electronics Product Plus Electronics $56.54 376 4.7 217 SKU-000482
483 Standard Food & Grocery Product Special Edition Food & Grocery $103.47 388 1.5 283 SKU-000483
484 Professional Sports & Outdoors Product 2024 Sports & Outdoors $563.71 43 3.2 779 SKU-000484
485 Super Sports & Outdoors Product Lite Sports & Outdoors $426.26 473 2.4 762 SKU-000485
486 Super Toys & Games Product Classic Toys & Games $621.60 225 1.3 261 SKU-000486
488 Standard Sports & Outdoors Product Pro Sports & Outdoors $546.60 310 4.0 485 SKU-000488
489 Premium Food & Grocery Product 2024 Food & Grocery $217.57 31 1.0 57 SKU-000489
490 Pro Books Product XL Books $903.70 258 3.8 577 SKU-000490
491 Ultra Office Supplies Product Max Office Supplies $553.61 371 2.4 275 SKU-000491
492 Elite Toys & Games Product Max Toys & Games $645.79 247 3.4 801 SKU-000492
493 Deluxe Automotive Product Advanced Automotive $866.01 8 1.9 820 SKU-000493
494 Standard Electronics Product Special Edition Electronics $145.78 306 4.4 660 SKU-000494
495 Elite Clothing Product XL Clothing $883.14 36 2.6 10 SKU-000495
496 Premium Automotive Product Advanced Automotive $155.99 497 2.3 658 SKU-000496
497 Premium Sports & Outdoors Product Plus Sports & Outdoors $318.57 155 1.8 178 SKU-000497
498 Deluxe Sports & Outdoors Product Advanced Sports & Outdoors $209.03 251 1.0 667 SKU-000498
499 Premium Home & Garden Product Advanced Home & Garden $31.31 329 4.1 11 SKU-000499
500 Professional Food & Grocery Product Pro Food & Grocery $202.85 131 2.1 998 SKU-000500
501 Super Toys & Games Product Special Edition Toys & Games $959.88 430 4.6 130 SKU-000501
502 Pro Toys & Games Product Lite Toys & Games $837.04 166 4.5 283 SKU-000502
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