Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

12 ms

Page Size

50

Current Page

142 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 142 Results Showing 7051 - 7100 of 24441

ID Name Category Price Stock Rating Reviews SKU
7610 Bulk Product 473d1c14 Home & Garden $879.47 340 0.1 24 BULK-3d96015b
7611 Bulk Product 7e07067b Electronics $180.19 74 2.5 82 BULK-73b686cf
7612 Bulk Product 3ecf86d7 Sports & Outdoors $257.11 230 4.2 95 BULK-0aab77b1
7613 Bulk Product 9fe94320 Home & Garden $430.06 19 0.2 62 BULK-2dcc31f0
7614 Bulk Product 0473372d Toys & Games $964.95 172 2.9 42 BULK-f1c9a695
7615 Bulk Product 7b688ac1 Clothing $325.94 477 2.6 4 BULK-a941ccde
7616 Bulk Product 67422891 Toys & Games $114.73 319 2.4 53 BULK-6eb386b4
7617 Bulk Product 3d3a2172 Toys & Games $253.60 204 2.7 78 BULK-13c8ba99
7618 Bulk Product 679de075 Electronics $850.51 408 4.3 75 BULK-7b0e36a3
7619 Bulk Product 2de5793a Toys & Games $579.34 75 1.8 76 BULK-1b5f2239
7620 Bulk Product 25e13985 Home & Garden $189.42 335 0.1 2 BULK-96eaae70
7621 Bulk Product 678638fd Clothing $268.69 72 3.3 50 BULK-30e1cd51
7622 Bulk Product 0beeee7d Clothing $771.47 327 0.9 1 BULK-87358818
7623 Bulk Product 4e54117f Clothing $182.61 345 0.1 13 BULK-6c5a6f53
7624 Bulk Product bfd2f531 Home & Garden $582.62 173 0.4 79 BULK-f8dd7fde
7625 Bulk Product 97e814b0 Electronics $562.49 175 2.7 72 BULK-1f46b067
7626 Bulk Product 0df6efb7 Sports & Outdoors $122.44 258 0.7 27 BULK-b4fb53d5
7627 Bulk Product 0b48d0ae Sports & Outdoors $593.18 465 0.3 49 BULK-46ede605
7628 Bulk Product fef15001 Home & Garden $361.56 199 1.3 40 BULK-a4913c60
7629 Bulk Product f910f94b Sports & Outdoors $797.07 489 1.8 88 BULK-4feda463
7630 Bulk Product 0d6fa358 Clothing $284.17 442 2.3 55 BULK-59e4cf69
7631 Bulk Product 1efe3204 Sports & Outdoors $847.16 295 1.4 83 BULK-359ce007
7632 Bulk Product aa10394b Sports & Outdoors $105.42 109 0.5 94 BULK-0426a9bc
7633 Bulk Product 14351ef0 Sports & Outdoors $10.75 77 2.4 66 BULK-32a94a0f
7634 Bulk Product 1e1c1134 Sports & Outdoors $630.70 271 4.7 9 BULK-d5bc2211
7635 Bulk Product 49ae11af Sports & Outdoors $370.64 331 4.5 3 BULK-30bd1283
7636 Bulk Product 4b2cdb93 Clothing $922.46 462 3.6 72 BULK-58879d87
7637 Bulk Product 98e90539 Sports & Outdoors $312.41 367 0.9 21 BULK-17bc9780
7638 Bulk Product 2a545256 Toys & Games $727.70 18 0.4 54 BULK-a8382986
7639 Bulk Product 7040b61c Sports & Outdoors $829.66 334 3.3 67 BULK-2bbb08ec
7640 Bulk Product 363f0071 Home & Garden $207.27 113 1.5 24 BULK-e20e5bad
7641 Bulk Product 38364d3b Sports & Outdoors $380.60 103 2.3 64 BULK-ac1e0b3d
7642 Bulk Product 73e2098f Toys & Games $311.31 84 3.4 96 BULK-ee7361d5
7643 Bulk Product 68b6c099 Electronics $37.05 428 2.4 53 BULK-8ccee8df
7644 Bulk Product a4628353 Clothing $630.06 41 2.3 11 BULK-f223e6a0
7645 Bulk Product 4354bedb Toys & Games $561.00 2 5.0 57 BULK-1e71ecd2
7646 Bulk Product 0458f5c4 Books $101.48 420 4.0 14 BULK-48ad7636
7647 Bulk Product 0cd0c7ba Clothing $351.09 314 4.2 47 BULK-2362ee9d
7648 Bulk Product 248594f5 Electronics $369.85 305 4.4 68 BULK-8fd34c24
7649 Bulk Product 6aa11051 Books $17.80 348 0.1 96 BULK-268b425d
7650 Bulk Product 93f010ab Home & Garden $937.16 143 1.5 94 BULK-09f2fb81
7651 Bulk Product 868c858e Home & Garden $692.54 161 0.5 21 BULK-dc19e7cb
7652 Bulk Product 158f8ba0 Clothing $538.85 229 1.9 14 BULK-cdf267e8
7653 Bulk Product b3e6ca12 Toys & Games $60.64 378 4.2 59 BULK-6f51ae3d
7654 Bulk Product a2117790 Home & Garden $76.81 9 0.5 19 BULK-90a429b9
7655 Bulk Product f2fe0680 Electronics $930.97 276 5.0 65 BULK-94b08f49
7656 Bulk Product 170d2510 Books $632.34 383 1.0 5 BULK-fcaf28a7
7657 Bulk Product f677c609 Home & Garden $730.71 333 4.6 68 BULK-08d64d7a
7658 Bulk Product df8ec88d Clothing $448.50 429 4.3 77 BULK-b28a86eb
7659 Bulk Product 0b59528a Home & Garden $202.78 494 4.7 36 BULK-93f91018
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