Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

9 ms

Page Size

50

Current Page

221 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 221 Results Showing 11001 - 11050 of 24441

ID Name Category Price Stock Rating Reviews SKU
11560 Bulk Product c33f8045 Sports & Outdoors $259.32 165 2.0 55 BULK-48de9628
11561 Bulk Product 801e8766 Clothing $463.70 417 1.3 84 BULK-b5e8a6dd
11562 Bulk Product bdcba066 Electronics $958.46 273 0.2 39 BULK-77c1f1c8
11563 Bulk Product 484742bb Books $628.41 454 2.9 5 BULK-67e46133
11564 Bulk Product caafa100 Sports & Outdoors $206.58 423 4.1 92 BULK-975b493d
11565 Bulk Product a9a1fe22 Books $980.76 79 3.4 20 BULK-b0e669f3
11566 Bulk Product 9caf72a7 Toys & Games $863.95 240 4.2 81 BULK-f4cba846
11567 Bulk Product 2f4b0076 Books $109.50 374 0.1 89 BULK-dc8ccfb0
11568 Bulk Product 910f2785 Electronics $830.42 190 3.9 84 BULK-286d3938
11569 Bulk Product 03064742 Home & Garden $298.52 90 3.7 73 BULK-19e5ebdd
11570 Bulk Product 7f7e0191 Books $397.59 366 1.6 79 BULK-5552a5b1
11571 Bulk Product 8ebff88f Home & Garden $981.75 131 0.5 47 BULK-9ea07028
11572 Bulk Product 8901c828 Toys & Games $445.48 330 2.9 70 BULK-359f0d06
11573 Bulk Product 7f057a51 Books $391.86 219 3.6 61 BULK-d296d1d1
11574 Bulk Product bc3cc67f Clothing $171.96 136 0.4 24 BULK-7b614979
11575 Bulk Product 12def21a Home & Garden $591.90 390 0.2 77 BULK-2ce687df
11576 Bulk Product 7ceee9ee Electronics $298.87 477 0.7 46 BULK-dc61f283
11577 Bulk Product 1cf64a1b Sports & Outdoors $702.66 240 3.2 45 BULK-57b81d60
11578 Bulk Product 8f00f991 Sports & Outdoors $513.03 90 3.4 97 BULK-88358b07
11579 Bulk Product 600ea73e Clothing $767.04 259 0.9 78 BULK-0eee03ea
11580 Bulk Product 54d39773 Sports & Outdoors $49.88 86 0.6 54 BULK-39ed44d1
11581 Bulk Product 80d15d3e Electronics $350.60 489 0.3 37 BULK-d3e32b0e
11582 Bulk Product 4813e208 Sports & Outdoors $798.96 442 4.0 3 BULK-040da4f4
11583 Bulk Product d2acaf3e Toys & Games $369.83 434 3.2 93 BULK-a6a41df3
11584 Bulk Product 084851d3 Home & Garden $802.64 453 0.7 26 BULK-ed028809
11585 Bulk Product 8f5b3a49 Sports & Outdoors $684.70 155 3.9 35 BULK-1582b8d4
11586 Bulk Product fd1c2d44 Clothing $778.88 404 3.3 19 BULK-774c972c
11587 Bulk Product 39d1d0dd Sports & Outdoors $597.49 12 2.3 57 BULK-7bc5c9a5
11588 Bulk Product f907bd98 Home & Garden $865.24 377 0.0 25 BULK-baf26ccf
11589 Bulk Product 63406ae5 Books $171.26 373 1.1 55 BULK-64611f96
11590 Bulk Product ec3c6809 Home & Garden $12.49 207 1.9 52 BULK-0443e7fe
11591 Bulk Product c6e2a984 Electronics $208.59 375 3.2 39 BULK-e1a49b50
11592 Bulk Product e6ac0ffc Books $50.64 495 3.0 94 BULK-f37f5e78
11593 Bulk Product 76e6833c Books $768.89 73 3.7 83 BULK-2cb3e375
11594 Bulk Product 261f8925 Toys & Games $575.34 162 3.2 47 BULK-60d0e8dc
11595 Bulk Product 488d9dba Clothing $228.31 329 0.9 57 BULK-84e0785f
11596 Bulk Product 57b9824a Books $799.62 314 4.0 0 BULK-0ba37896
11597 Bulk Product 0dfb65c7 Toys & Games $465.58 219 4.2 87 BULK-0775b740
11598 Bulk Product 8b474259 Sports & Outdoors $283.21 173 2.1 22 BULK-f608c0c9
11599 Bulk Product 898d387d Toys & Games $650.49 217 1.4 29 BULK-9bf4f2fb
11600 Bulk Product 806280a8 Books $172.30 118 4.6 82 BULK-d74b93ef
11601 Bulk Product 2a3c3322 Toys & Games $94.69 386 1.9 84 BULK-190353e4
11602 Bulk Product 681ae667 Books $832.72 131 1.2 57 BULK-b52ed385
11603 Bulk Product ce93dfe8 Sports & Outdoors $468.57 324 0.9 26 BULK-082c6608
11604 Bulk Product fe996e50 Sports & Outdoors $957.83 312 0.5 18 BULK-78401666
11605 Bulk Product 5911d988 Home & Garden $901.52 283 0.5 72 BULK-ff7ba3a1
11606 Bulk Product 1a92d3a6 Sports & Outdoors $489.61 67 3.9 65 BULK-ae00415d
11607 Bulk Product 595388f3 Toys & Games $453.38 251 1.5 63 BULK-dea08361
11608 Bulk Product 69c82eae Clothing $861.59 266 3.3 72 BULK-e1072cba
11609 Bulk Product c7cfdeb3 Toys & Games $462.60 9 4.4 22 BULK-98180522
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