Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

10 ms

Page Size

50

Current Page

138 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 138 Results Showing 6851 - 6900 of 24441

ID Name Category Price Stock Rating Reviews SKU
7410 Bulk Product 0b249076 Books $73.84 441 2.8 87 BULK-043af8aa
7411 Bulk Product 08b91c1f Electronics $514.53 339 1.4 12 BULK-796406a6
7412 Bulk Product e8c6ce59 Toys & Games $267.36 459 1.5 40 BULK-6f832aec
7413 Bulk Product ff048c57 Sports & Outdoors $116.21 102 3.7 20 BULK-63d624a6
7414 Bulk Product b89e5ed9 Sports & Outdoors $245.58 109 4.2 2 BULK-685454af
7415 Bulk Product a1ecc29d Books $140.89 27 2.9 21 BULK-07658786
7416 Bulk Product 372904b0 Clothing $843.90 189 4.7 81 BULK-2f0bab06
7417 Bulk Product 2e3b9c8f Home & Garden $276.56 399 4.0 61 BULK-7817d41e
7418 Bulk Product a601a97d Home & Garden $324.94 402 4.7 64 BULK-05145354
7419 Bulk Product fe5b14b3 Clothing $711.94 225 2.2 68 BULK-c56a2783
7420 Bulk Product f6f7a58f Electronics $724.93 356 4.8 76 BULK-40e40168
7421 Bulk Product b8212e3d Books $849.69 465 0.2 35 BULK-ac65bd52
7422 Bulk Product 5e75b7f8 Home & Garden $301.85 32 2.2 48 BULK-72d1cbb0
7423 Bulk Product 2ca91a9c Home & Garden $745.19 268 4.5 10 BULK-10932aac
7424 Bulk Product 95f06651 Electronics $874.37 300 0.5 42 BULK-ffef6bc0
7425 Bulk Product 2c45adf8 Books $952.97 26 4.3 95 BULK-4ae1bc39
7426 Bulk Product bfd21532 Home & Garden $147.65 425 1.8 14 BULK-1c225a9d
7427 Bulk Product 4924cdd1 Books $411.90 347 4.3 48 BULK-00e38d48
7428 Bulk Product adbe6332 Home & Garden $519.44 7 1.9 87 BULK-83eac106
7429 Bulk Product 55223159 Clothing $741.05 256 4.9 4 BULK-bd537b4d
7430 Bulk Product 2ec37f2e Toys & Games $941.02 99 4.0 45 BULK-a54bb382
7431 Bulk Product eb4fc0a5 Sports & Outdoors $865.74 424 3.5 48 BULK-92ea0683
7432 Bulk Product 22da3bb7 Clothing $185.52 459 4.5 51 BULK-fe853161
7433 Bulk Product 92761e59 Home & Garden $435.81 230 4.1 24 BULK-78ce9a2f
7434 Bulk Product ce1853cb Sports & Outdoors $507.76 174 1.4 55 BULK-395a3bb5
7435 Bulk Product ca79ff88 Books $623.44 44 2.6 37 BULK-3de65f94
7436 Bulk Product 2c674e0c Clothing $603.97 67 4.2 86 BULK-74c3ffb2
7437 Bulk Product 4a8b1eab Books $304.72 181 2.8 34 BULK-51d87dfc
7438 Bulk Product 50395b30 Clothing $185.86 74 2.0 9 BULK-6697d578
7439 Bulk Product eed34066 Books $262.97 176 3.2 67 BULK-86a10679
7440 Bulk Product a450018b Clothing $980.78 465 1.6 70 BULK-bbd12093
7441 Bulk Product 726fbfd6 Sports & Outdoors $87.74 250 4.2 41 BULK-11482033
7442 Bulk Product 69b98569 Home & Garden $398.81 102 1.7 17 BULK-866bd267
7443 Bulk Product cfd96963 Electronics $190.47 205 3.9 42 BULK-f757261f
7444 Bulk Product 2822591a Home & Garden $642.96 363 3.3 23 BULK-8989b2a3
7445 Bulk Product 5a991746 Home & Garden $436.73 409 2.9 69 BULK-eef0e28d
7446 Bulk Product dc29d4bc Books $812.36 126 1.8 85 BULK-8fea9baf
7447 Bulk Product 47e04d39 Books $670.74 450 2.9 39 BULK-c256de57
7448 Bulk Product d5cf5c52 Books $153.57 176 4.5 23 BULK-8f4805a5
7449 Bulk Product d9412afa Clothing $169.60 267 2.7 81 BULK-3ea9b8f3
7450 Bulk Product beef2e22 Clothing $78.65 140 0.2 96 BULK-a26da253
7451 Bulk Product 6f088d36 Clothing $71.62 140 4.8 9 BULK-d3733c4a
7452 Bulk Product c35dc320 Books $893.80 450 4.0 14 BULK-284c95b8
7453 Bulk Product e655676d Clothing $888.73 353 4.6 5 BULK-a9dbb127
7454 Bulk Product cd37c24e Home & Garden $68.04 271 0.6 6 BULK-d416453b
7455 Bulk Product 6b759f1b Home & Garden $122.52 202 0.2 34 BULK-6f651399
7456 Bulk Product df7ae649 Clothing $397.94 239 3.3 56 BULK-269ac0c5
7457 Bulk Product 2c8aeab0 Toys & Games $21.05 101 1.8 11 BULK-9264a11d
7458 Bulk Product ea31ec64 Electronics $627.69 376 1.7 38 BULK-187e882f
7459 Bulk Product 26813ca1 Home & Garden $945.31 492 2.5 58 BULK-a6251080
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