Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

14 ms

Page Size

50

Current Page

79 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 79 Results Showing 3901 - 3950 of 24441

ID Name Category Price Stock Rating Reviews SKU
4388 Mega Sports & Outdoors Product 2024 Sports & Outdoors $89.64 300 3.2 464 SKU-004388
4389 Elite Automotive Product 2024 Automotive $519.37 411 3.3 197 SKU-004389
4391 Pro Health & Beauty Product Pro Health & Beauty $126.22 230 4.3 607 SKU-004391
4392 Elite Sports & Outdoors Product Pro Sports & Outdoors $426.60 70 3.6 293 SKU-004392
4393 Standard Sports & Outdoors Product Advanced Sports & Outdoors $831.76 142 3.8 281 SKU-004393
4394 Standard Electronics Product Special Edition Electronics $596.57 118 3.6 769 SKU-004394
4397 Pro Home & Garden Product Special Edition Home & Garden $415.76 420 2.5 692 SKU-004397
4398 Elite Electronics Product Special Edition Electronics $162.02 436 2.7 900 SKU-004398
4399 Mega Health & Beauty Product Max Health & Beauty $477.82 149 1.4 878 SKU-004399
4400 Ultra Clothing Product Plus Clothing $650.96 90 1.8 476 SKU-004400
4401 Deluxe Electronics Product Pro Electronics $963.03 62 1.7 237 SKU-004401
4402 Economy Food & Grocery Product 2024 Food & Grocery $105.70 82 2.6 79 SKU-004402
4403 Super Automotive Product Lite Automotive $838.39 274 3.2 238 SKU-004403
4404 Professional Office Supplies Product XL Office Supplies $803.61 243 3.2 681 SKU-004404
4406 Premium Office Supplies Product Max Office Supplies $670.79 58 4.6 659 SKU-004406
4407 Standard Automotive Product Mini Automotive $567.68 149 3.0 220 SKU-004407
4408 Super Office Supplies Product Lite Office Supplies $373.82 416 1.5 828 SKU-004408
4409 Mega Office Supplies Product Lite Office Supplies $215.56 204 4.7 406 SKU-004409
4410 Super Office Supplies Product Mini Office Supplies $613.86 186 4.9 133 SKU-004410
4411 Professional Health & Beauty Product Pro Health & Beauty $690.41 173 4.7 988 SKU-004411
4412 Premium Books Product Special Edition Books $381.45 190 3.1 513 SKU-004412
4413 Elite Sports & Outdoors Product Advanced Sports & Outdoors $638.70 407 3.8 569 SKU-004413
4414 Ultra Automotive Product Max Automotive $441.43 80 3.1 609 SKU-004414
4415 Deluxe Health & Beauty Product Classic Health & Beauty $492.36 464 4.5 397 SKU-004415
4417 Deluxe Office Supplies Product Mini Office Supplies $742.49 358 3.0 621 SKU-004417
4419 Deluxe Books Product Classic Books $173.21 176 4.4 366 SKU-004419
4420 Super Sports & Outdoors Product Pro Sports & Outdoors $888.68 5 1.3 537 SKU-004420
4421 Pro Books Product Plus Books $135.42 26 4.1 119 SKU-004421
4422 Professional Automotive Product Lite Automotive $975.62 378 1.1 187 SKU-004422
4423 Deluxe Health & Beauty Product Lite Health & Beauty $734.10 33 1.5 61 SKU-004423
4424 Super Sports & Outdoors Product Advanced Sports & Outdoors $843.79 84 2.7 33 SKU-004424
4425 Super Home & Garden Product Classic Home & Garden $893.40 178 4.1 226 SKU-004425
4426 Super Health & Beauty Product Plus Health & Beauty $715.83 159 2.6 932 SKU-004426
4428 Elite Health & Beauty Product Special Edition Health & Beauty $846.61 417 4.8 164 SKU-004428
4429 Ultra Office Supplies Product Classic Office Supplies $795.86 44 3.3 197 SKU-004429
4430 Elite Home & Garden Product Special Edition Home & Garden $188.39 404 3.4 48 SKU-004430
4431 Pro Sports & Outdoors Product Mini Sports & Outdoors $375.18 183 3.0 265 SKU-004431
4432 Mega Home & Garden Product Mini Home & Garden $246.10 281 4.7 479 SKU-004432
4433 Deluxe Food & Grocery Product Max Food & Grocery $21.62 15 1.1 109 SKU-004433
4436 Super Books Product Advanced Books $993.33 180 1.8 533 SKU-004436
4437 Premium Office Supplies Product Pro Office Supplies $900.06 302 2.1 350 SKU-004437
4438 Pro Clothing Product Pro Clothing $889.59 135 4.9 649 SKU-004438
4439 Deluxe Food & Grocery Product 2024 Food & Grocery $586.59 380 1.8 76 SKU-004439
4441 Professional Clothing Product Advanced Clothing $159.81 58 3.7 456 SKU-004441
4442 Mega Home & Garden Product XL Home & Garden $465.50 299 2.5 984 SKU-004442
4443 Pro Health & Beauty Product Lite Health & Beauty $419.16 303 1.5 774 SKU-004443
4444 Pro Home & Garden Product Lite Home & Garden $865.19 150 4.2 722 SKU-004444
4445 Standard Sports & Outdoors Product 2024 Sports & Outdoors $801.83 478 2.6 884 SKU-004445
4446 Premium Electronics Product Advanced Electronics $516.26 173 1.2 626 SKU-004446
4447 Elite Food & Grocery Product Classic Food & Grocery $543.07 385 3.1 594 SKU-004447
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