Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

30 ms

Page Size

50

Current Page

460 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 460 Results Showing 22951 - 23000 of 24441

ID Name Category Price Stock Rating Reviews SKU
23510 Bulk Product d58b8702 Sports & Outdoors $408.98 409 2.7 55 BULK-e4eb910d
23511 Bulk Product ce966fbe Sports & Outdoors $426.99 481 0.7 12 BULK-a3db6812
23512 Bulk Product 933f1ee3 Electronics $670.78 423 1.3 3 BULK-2c28fb5b
23513 Bulk Product f7604dd6 Toys & Games $672.64 386 4.9 38 BULK-b57e1495
23514 Bulk Product b7343708 Home & Garden $761.15 120 2.0 17 BULK-44a3dd67
23515 Bulk Product 758810e2 Home & Garden $134.95 465 1.9 11 BULK-23e9d0d7
23516 Bulk Product 234fa277 Sports & Outdoors $277.61 271 3.2 91 BULK-231265fc
23517 Bulk Product 4a18a2bd Books $282.04 449 3.0 9 BULK-04f1b038
23518 Bulk Product 54382fc7 Clothing $311.29 87 1.7 15 BULK-d100ab02
23519 Bulk Product 09563180 Clothing $412.87 366 0.7 18 BULK-303598e8
23520 Bulk Product 7ec756c6 Toys & Games $933.28 193 5.0 62 BULK-7a988293
23521 Bulk Product 5f34ee3a Sports & Outdoors $939.50 270 1.7 21 BULK-64ab4442
23522 Bulk Product b950d510 Electronics $218.67 160 4.1 91 BULK-34caf852
23523 Bulk Product 6c0fbcbb Books $202.66 365 4.1 34 BULK-5fa5411c
23524 Bulk Product 58a09d46 Clothing $483.76 143 4.7 15 BULK-037dc983
23525 Bulk Product 0ecdd67d Home & Garden $803.99 466 4.7 49 BULK-914ee53f
23526 Bulk Product 88a4c86d Sports & Outdoors $129.83 49 2.5 84 BULK-15da5b8e
23527 Bulk Product 72e18d17 Clothing $822.80 462 1.8 72 BULK-45e82c7f
23528 Bulk Product 16cd87e2 Home & Garden $277.90 167 0.9 77 BULK-5176d8a7
23529 Bulk Product 357db3c4 Electronics $827.10 14 4.4 51 BULK-3d70a971
23530 Bulk Product 4dc7dbab Home & Garden $470.37 355 2.3 51 BULK-68f02dc6
23531 Bulk Product fd33d38d Electronics $930.10 200 1.5 60 BULK-d752102b
23532 Bulk Product 4cfcb9f7 Clothing $705.98 360 3.0 20 BULK-6369223a
23533 Bulk Product e3918c48 Sports & Outdoors $395.72 230 4.8 44 BULK-c4facc61
23534 Bulk Product 0556b97a Sports & Outdoors $37.58 406 3.8 91 BULK-b2b629ba
23535 Bulk Product 3797f749 Toys & Games $46.06 297 3.5 42 BULK-df2b1b52
23536 Bulk Product 7b728df7 Electronics $228.28 464 2.1 13 BULK-4551ce61
23537 Bulk Product 4471fc17 Home & Garden $492.66 94 3.7 11 BULK-d10e8bc5
23538 Bulk Product f43450f2 Sports & Outdoors $235.54 460 1.6 73 BULK-0e985cf2
23539 Bulk Product 471d0c68 Clothing $559.59 70 1.2 62 BULK-2ab96db1
23540 Bulk Product eef76ad3 Books $260.90 225 0.4 35 BULK-becac8a4
23541 Bulk Product 8d30e158 Home & Garden $977.45 264 4.0 18 BULK-598a8813
23542 Bulk Product 32a0af4c Toys & Games $172.99 49 4.5 55 BULK-2562e7c4
23543 Bulk Product 78d6eb37 Toys & Games $806.58 92 1.3 19 BULK-339a6898
23544 Bulk Product 0ee0364e Clothing $864.16 418 0.2 24 BULK-34538537
23545 Bulk Product 3bedde81 Clothing $531.53 436 4.2 35 BULK-b9ccce2e
23546 Bulk Product 2605481f Toys & Games $745.27 221 1.6 40 BULK-412e6f0a
23547 Bulk Product 25ee3129 Books $44.45 246 0.6 40 BULK-25897c62
23548 Bulk Product 524a8a9c Sports & Outdoors $652.59 291 0.3 91 BULK-7eb2ba07
23549 Bulk Product fe3d5d1a Home & Garden $756.79 255 0.3 25 BULK-4837f5ce
23550 Bulk Product 2ed10240 Books $188.71 342 0.4 93 BULK-866efdca
23551 Bulk Product fbfafb8e Home & Garden $215.23 202 0.7 0 BULK-69019265
23552 Bulk Product dc456086 Home & Garden $24.49 333 2.8 11 BULK-af5d5642
23553 Bulk Product 2eba078f Electronics $338.39 91 2.5 71 BULK-f104261b
23554 Bulk Product 52284ede Sports & Outdoors $767.75 448 2.7 99 BULK-057c46ef
23555 Bulk Product bf3f8b95 Sports & Outdoors $841.13 268 1.4 93 BULK-47d10d24
23556 Bulk Product a41ddd21 Clothing $33.70 273 2.1 57 BULK-19668847
23557 Bulk Product d2285aad Electronics $876.90 221 0.2 8 BULK-6cdf7a59
23558 Bulk Product ec860144 Books $707.59 221 0.3 43 BULK-dc18c954
23559 Bulk Product 0408a7b6 Home & Garden $550.43 440 2.6 89 BULK-9b208be8
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