Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

10 ms

Page Size

50

Current Page

141 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 141 Results Showing 7001 - 7050 of 24441

ID Name Category Price Stock Rating Reviews SKU
7560 Bulk Product 92404f01 Home & Garden $235.73 24 2.5 20 BULK-6034c3e4
7561 Bulk Product 921fe5ba Toys & Games $230.36 469 1.4 22 BULK-210ebcbf
7562 Bulk Product 63966404 Home & Garden $385.07 119 4.3 26 BULK-30a3a2d2
7563 Bulk Product d6eb6db6 Clothing $762.50 237 4.3 50 BULK-024ca7ca
7564 Bulk Product 3e1f3b4d Home & Garden $464.39 335 2.1 90 BULK-fa2796fc
7565 Bulk Product 66a0beac Electronics $228.89 170 3.2 90 BULK-4051df64
7566 Bulk Product 1857f626 Toys & Games $613.57 31 1.4 4 BULK-c8e547f1
7567 Bulk Product 628f91b8 Toys & Games $384.53 112 1.5 4 BULK-a47672bb
7568 Bulk Product 37522dec Home & Garden $188.14 138 3.7 68 BULK-c67eb6b1
7569 Bulk Product cbe2c0fa Home & Garden $980.18 491 5.0 21 BULK-08547858
7570 Bulk Product 4ea91e69 Books $862.14 88 4.7 24 BULK-ae5d20aa
7571 Bulk Product a1f5afe6 Clothing $369.03 161 0.9 69 BULK-1229aed1
7572 Bulk Product e9984c0f Clothing $342.82 97 1.5 14 BULK-9bb28deb
7573 Bulk Product 954aae76 Home & Garden $223.33 451 0.1 18 BULK-da5628e9
7574 Bulk Product 433d510b Sports & Outdoors $883.36 269 0.7 92 BULK-640aa399
7575 Bulk Product b8ad3981 Toys & Games $370.73 377 1.3 78 BULK-bae71283
7576 Bulk Product c2930764 Toys & Games $93.00 165 4.6 53 BULK-63be1880
7577 Bulk Product 195c6652 Home & Garden $215.04 296 2.2 36 BULK-208067ce
7578 Bulk Product caf408eb Clothing $26.17 29 3.3 22 BULK-fad971b9
7579 Bulk Product 0d4c4d97 Home & Garden $745.43 339 3.3 70 BULK-197bde41
7580 Bulk Product ebc69213 Clothing $136.73 163 4.1 90 BULK-5db1db13
7581 Bulk Product cef62272 Clothing $814.73 56 2.5 87 BULK-6bb4b9f4
7582 Bulk Product 0e7d249b Toys & Games $799.88 388 3.0 73 BULK-9efcceb5
7583 Bulk Product 9a6225d8 Home & Garden $350.46 273 3.2 86 BULK-91c78d6f
7584 Bulk Product 6418f8b7 Sports & Outdoors $926.52 279 0.4 23 BULK-cb4ab8c2
7585 Bulk Product 0cd6d851 Books $394.82 310 3.1 16 BULK-3cf79424
7586 Bulk Product 38f09701 Toys & Games $182.60 470 1.4 29 BULK-a12c3580
7587 Bulk Product ea398550 Clothing $953.35 42 4.9 88 BULK-cdad1a14
7588 Bulk Product 9560355f Electronics $512.26 430 3.0 42 BULK-86d9a25b
7589 Bulk Product ecc17795 Clothing $445.85 38 4.6 84 BULK-1f668483
7590 Bulk Product 2175fc2c Sports & Outdoors $512.73 298 0.5 79 BULK-de57378b
7591 Bulk Product 480b63bd Sports & Outdoors $267.11 330 3.6 95 BULK-0399bb41
7592 Bulk Product d73c9239 Clothing $875.00 77 4.1 57 BULK-8a14b063
7593 Bulk Product 30552286 Books $501.66 33 4.9 48 BULK-42441b7e
7594 Bulk Product d878609a Clothing $785.60 345 3.6 99 BULK-eceb64cf
7595 Bulk Product b7a040b8 Clothing $107.15 143 1.3 24 BULK-a3c13f32
7596 Bulk Product 02725640 Books $743.20 305 4.0 20 BULK-678cedf7
7597 Bulk Product d7ece429 Books $961.41 265 4.7 54 BULK-248f8120
7598 Bulk Product f98f5b61 Toys & Games $356.81 290 1.7 8 BULK-02a5925a
7599 Bulk Product c5fb9c56 Electronics $83.89 333 4.7 66 BULK-5a5da07e
7600 Bulk Product dc9990fc Clothing $590.76 157 1.8 50 BULK-4cc8bb52
7601 Bulk Product 17b6f525 Sports & Outdoors $446.82 364 2.8 43 BULK-8ad1cf54
7602 Bulk Product 4124c12e Books $978.27 463 2.6 3 BULK-7fb71b68
7603 Bulk Product 07e9e890 Toys & Games $818.55 88 4.9 87 BULK-c5b656c6
7604 Bulk Product 1029cdf9 Electronics $714.34 145 0.1 3 BULK-3be2bdcd
7605 Bulk Product 6258754a Electronics $934.77 368 0.8 31 BULK-5ad1b94d
7606 Bulk Product 43983255 Home & Garden $62.48 11 3.9 16 BULK-bec99954
7607 Bulk Product 19f2982d Books $388.89 301 0.5 40 BULK-7b4da032
7608 Bulk Product a1af767a Sports & Outdoors $161.06 257 1.7 50 BULK-1668bb50
7609 Bulk Product e0371cd4 Home & Garden $377.82 56 0.8 38 BULK-33efb414
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