Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

12 ms

Page Size

50

Current Page

80 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 80 Results Showing 3951 - 4000 of 24441

ID Name Category Price Stock Rating Reviews SKU
4448 Standard Office Supplies Product 2024 Office Supplies $303.87 299 3.1 916 SKU-004448
4449 Ultra Home & Garden Product Classic Home & Garden $857.23 273 3.3 493 SKU-004449
4450 Premium Office Supplies Product Advanced Office Supplies $820.60 455 4.4 597 SKU-004450
4454 Standard Sports & Outdoors Product Advanced Sports & Outdoors $281.68 230 3.7 118 SKU-004454
4455 Pro Sports & Outdoors Product Pro Sports & Outdoors $196.57 382 1.3 584 SKU-004455
4456 Economy Home & Garden Product 2024 Home & Garden $377.41 446 4.6 885 SKU-004456
4458 Super Books Product Max Books $248.32 91 4.4 90 SKU-004458
4459 Super Health & Beauty Product Classic Health & Beauty $202.51 129 3.9 628 SKU-004459
4460 Super Food & Grocery Product XL Food & Grocery $920.72 124 2.5 44 SKU-004460
4461 Premium Electronics Product Classic Electronics $373.89 478 3.2 417 SKU-004461
4462 Elite Health & Beauty Product Pro Health & Beauty $895.20 498 3.7 926 SKU-004462
4464 Deluxe Automotive Product Max Automotive $154.52 373 1.8 183 SKU-004464
4465 Pro Home & Garden Product Classic Home & Garden $389.73 492 1.2 549 SKU-004465
4466 Deluxe Office Supplies Product Lite Office Supplies $938.86 101 4.5 375 SKU-004466
4467 Standard Books Product Pro Books $409.32 9 4.8 262 SKU-004467
4468 Mega Office Supplies Product Special Edition Office Supplies $934.75 438 1.4 55 SKU-004468
4469 Standard Toys & Games Product Pro Toys & Games $985.46 0 1.7 305 SKU-004469
4470 Standard Electronics Product Advanced Electronics $837.73 49 4.1 695 SKU-004470
4471 Deluxe Books Product Mini Books $573.18 135 4.5 372 SKU-004471
4472 Standard Sports & Outdoors Product Mini Sports & Outdoors $878.70 291 1.4 635 SKU-004472
4473 Deluxe Books Product Special Edition Books $949.59 178 3.4 300 SKU-004473
4474 Mega Electronics Product XL Electronics $900.75 224 2.8 946 SKU-004474
4475 Mega Clothing Product Advanced Clothing $744.30 451 3.9 752 SKU-004475
4477 Pro Sports & Outdoors Product Special Edition Sports & Outdoors $485.92 131 3.4 848 SKU-004477
4478 Mega Toys & Games Product Mini Toys & Games $26.84 290 3.9 810 SKU-004478
4479 Economy Office Supplies Product Lite Office Supplies $229.36 205 1.8 437 SKU-004479
4480 Ultra Sports & Outdoors Product Special Edition Sports & Outdoors $137.23 465 4.1 665 SKU-004480
4481 Super Office Supplies Product Max Office Supplies $873.99 59 2.4 572 SKU-004481
4482 Ultra Home & Garden Product Special Edition Home & Garden $678.50 346 3.7 820 SKU-004482
4483 Standard Home & Garden Product Mini Home & Garden $864.44 224 1.6 161 SKU-004483
4485 Premium Electronics Product Special Edition Electronics $509.07 263 1.2 727 SKU-004485
4486 Deluxe Books Product 2024 Books $194.97 497 3.8 996 SKU-004486
4487 Super Automotive Product Mini Automotive $57.26 494 2.1 316 SKU-004487
4488 Deluxe Automotive Product Mini Automotive $191.47 489 3.8 913 SKU-004488
4489 Deluxe Health & Beauty Product Pro Health & Beauty $144.37 273 2.5 126 SKU-004489
4490 Ultra Office Supplies Product Plus Office Supplies $109.68 85 3.4 755 SKU-004490
4491 Ultra Clothing Product Max Clothing $975.26 177 2.5 172 SKU-004491
4492 Ultra Electronics Product Plus Electronics $411.13 103 1.9 266 SKU-004492
4493 Deluxe Electronics Product Lite Electronics $134.55 99 4.6 83 SKU-004493
4494 Super Books Product Advanced Books $552.13 274 1.9 298 SKU-004494
4495 Standard Automotive Product Classic Automotive $70.81 1 1.5 883 SKU-004495
4496 Premium Toys & Games Product Pro Toys & Games $961.19 121 3.5 756 SKU-004496
4497 Premium Sports & Outdoors Product Pro Sports & Outdoors $79.89 182 4.2 385 SKU-004497
4498 Deluxe Sports & Outdoors Product 2024 Sports & Outdoors $88.07 389 2.7 306 SKU-004498
4499 Elite Clothing Product XL Clothing $751.87 471 4.1 508 SKU-004499
4500 Professional Clothing Product Plus Clothing $353.06 363 3.1 566 SKU-004500
4501 Ultra Food & Grocery Product Plus Food & Grocery $451.54 406 4.9 891 SKU-004501
4503 Deluxe Sports & Outdoors Product Max Sports & Outdoors $428.66 378 2.8 706 SKU-004503
4504 Professional Office Supplies Product Mini Office Supplies $634.73 266 3.9 223 SKU-004504
4505 Super Electronics Product Advanced Electronics $981.49 327 3.6 640 SKU-004505
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