Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

46 ms

Page Size

50

Current Page

463 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 463 Results Showing 23101 - 23150 of 24441

ID Name Category Price Stock Rating Reviews SKU
23660 Bulk Product 0cd568bf Clothing $647.07 473 4.8 34 BULK-366bbaaf
23661 Bulk Product d99c4bca Home & Garden $940.19 467 1.2 91 BULK-26f00dac
23662 Bulk Product ee4e507e Home & Garden $588.46 494 0.3 20 BULK-ba4555b5
23663 Bulk Product 7ba6d674 Clothing $493.54 499 2.3 93 BULK-8f399ed9
23664 Bulk Product 5ea84272 Electronics $558.57 235 1.1 27 BULK-753c9d91
23665 Bulk Product 88ee48d7 Clothing $707.86 216 1.2 99 BULK-e119b028
23666 Bulk Product 5dacadc6 Sports & Outdoors $1,002.18 393 0.9 97 BULK-35f9ecfd
23667 Bulk Product 24365987 Sports & Outdoors $828.64 374 4.8 17 BULK-3472a5e9
23668 Bulk Product 956616a4 Clothing $121.64 163 3.4 60 BULK-f18bab18
23669 Bulk Product e872383c Books $874.60 186 3.8 57 BULK-f696770a
23670 Bulk Product 08199fcd Clothing $805.43 447 1.7 18 BULK-8cf79b1d
23671 Bulk Product 4d1e508a Books $976.28 88 3.5 88 BULK-c489461e
23672 Bulk Product 437d894b Home & Garden $330.19 78 1.7 83 BULK-645dd178
23673 Bulk Product 110a948b Books $450.82 189 3.9 25 BULK-f9940e46
23674 Bulk Product 77f4502d Electronics $645.55 228 0.5 32 BULK-59f1f8c6
23675 Bulk Product 0d21ed75 Sports & Outdoors $985.94 211 2.8 95 BULK-74ab1412
23676 Bulk Product b50e5426 Electronics $700.46 136 2.4 49 BULK-c559c15e
23677 Bulk Product 9eaaa0b5 Sports & Outdoors $117.37 439 1.6 19 BULK-8c2d538b
23678 Bulk Product 2c005a83 Clothing $192.01 142 0.5 23 BULK-864d7c01
23679 Bulk Product 51378778 Electronics $275.99 335 4.5 14 BULK-e4c9d106
23680 Bulk Product e714ef28 Sports & Outdoors $571.55 225 1.8 99 BULK-03a8938d
23681 Bulk Product a7b2a90c Clothing $349.00 426 2.5 47 BULK-a70d2046
23682 Bulk Product c77f32b8 Books $384.53 112 4.1 17 BULK-6addbf92
23683 Bulk Product b0462c6f Toys & Games $166.42 452 4.5 19 BULK-21077b17
23684 Bulk Product 740b8bc7 Clothing $806.72 485 2.1 29 BULK-3d010f09
23685 Bulk Product 62414df9 Sports & Outdoors $295.48 347 4.7 26 BULK-1be6ee5d
23686 Bulk Product 432cd0fd Electronics $979.04 122 1.8 7 BULK-cbe88c8b
23687 Bulk Product bad3b76e Books $905.11 296 3.6 45 BULK-f606480d
23688 Bulk Product a1dfa2bc Books $450.41 41 0.7 52 BULK-75363431
23689 Bulk Product 93e560dd Home & Garden $242.24 481 2.5 2 BULK-bd635da1
23690 Bulk Product a26ecc97 Sports & Outdoors $710.42 61 0.3 67 BULK-826a445c
23691 Bulk Product 28db3076 Toys & Games $318.96 452 3.8 83 BULK-1e1703e3
23692 Bulk Product bd8d0953 Electronics $690.73 269 0.8 17 BULK-76925003
23693 Bulk Product 9968dbfb Toys & Games $135.83 48 1.0 47 BULK-924a08cc
23694 Bulk Product 17cee009 Clothing $184.27 325 1.8 74 BULK-8a786794
23695 Bulk Product 8c64d46b Toys & Games $783.39 164 1.3 54 BULK-3e8d15c8
23696 Bulk Product 81464c69 Home & Garden $792.17 133 0.9 24 BULK-dcba5ad3
23697 Bulk Product e167ef41 Toys & Games $121.74 289 3.2 67 BULK-be45aafa
23698 Bulk Product e0686779 Toys & Games $74.42 300 4.9 18 BULK-73065c12
23699 Bulk Product b86f0f29 Sports & Outdoors $459.10 327 5.0 61 BULK-e41f03f1
23700 Bulk Product fe0e9deb Toys & Games $223.36 400 0.1 13 BULK-2a2b698e
23701 Bulk Product 3f5a2e86 Toys & Games $515.23 70 3.7 48 BULK-34707e15
23702 Bulk Product 8f6301da Electronics $248.55 4 3.5 41 BULK-fde8ee65
23703 Bulk Product a42df177 Toys & Games $360.63 172 4.9 15 BULK-0e14742e
23704 Bulk Product 8d2581d2 Toys & Games $637.62 176 3.9 78 BULK-49ec2aa8
23705 Bulk Product aad20c8e Toys & Games $385.54 366 4.6 75 BULK-bab475ff
23706 Bulk Product 7c66edb7 Clothing $784.65 117 3.3 74 BULK-d2a5cfc7
23707 Bulk Product e21190e1 Books $800.91 21 4.6 17 BULK-94aa3b78
23708 Bulk Product 504f2e2f Home & Garden $321.88 408 3.9 32 BULK-5116fead
23709 Bulk Product f41f57f0 Sports & Outdoors $98.01 335 3.3 89 BULK-03a11288
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