Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

21 ms

Page Size

50

Current Page

107 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 107 Results Showing 5301 - 5350 of 24441

ID Name Category Price Stock Rating Reviews SKU
5860 Bulk Product 330f3a89 Electronics $256.76 330 1.0 57 BULK-11b0713e
5861 Bulk Product accee818 Sports & Outdoors $528.54 40 2.7 99 BULK-6c240704
5862 Bulk Product 2846b2d7 Electronics $16.55 20 3.3 78 BULK-a9c838a6
5863 Bulk Product 1917215a Toys & Games $623.28 430 4.2 13 BULK-e99f8cbb
5864 Bulk Product bb5d1318 Home & Garden $334.86 336 2.2 35 BULK-4e6aaf7b
5865 Bulk Product 571784a5 Sports & Outdoors $81.15 27 3.1 72 BULK-6655be7a
5866 Bulk Product 738787f6 Toys & Games $122.32 475 2.3 16 BULK-b37cfec6
5867 Bulk Product 52274214 Sports & Outdoors $546.91 73 0.5 25 BULK-d3e8e676
5868 Bulk Product 7f9d118d Clothing $573.11 101 4.4 72 BULK-cd485633
5869 Bulk Product 6c201971 Sports & Outdoors $293.89 36 0.3 26 BULK-aa0def41
5870 Bulk Product 79255219 Clothing $174.33 346 0.4 5 BULK-98e778e6
5871 Bulk Product d4921895 Sports & Outdoors $550.39 377 4.4 56 BULK-bfbe77ad
5872 Bulk Product 03e727c2 Books $455.13 381 1.7 76 BULK-6bf5de43
5873 Bulk Product 58417bda Clothing $570.93 400 2.0 90 BULK-8bb65b4e
5874 Bulk Product 53e80fd0 Books $259.28 416 2.6 73 BULK-8ee65b4f
5875 Bulk Product 27fbba83 Home & Garden $612.07 104 4.6 35 BULK-792ae9df
5876 Bulk Product 1fc90760 Clothing $542.53 345 4.8 58 BULK-9081139b
5877 Bulk Product 7414e96c Books $624.46 293 3.6 17 BULK-1d48fe1e
5878 Bulk Product 5d5187f1 Clothing $258.42 368 1.2 9 BULK-3b4ad242
5879 Bulk Product 710bb3ee Books $253.37 140 2.8 72 BULK-16d13eef
5880 Bulk Product fcf002b1 Books $635.65 258 3.6 12 BULK-38a0c2c2
5881 Bulk Product 1d6de4d1 Clothing $601.66 192 1.3 29 BULK-949b52ae
5882 Bulk Product 9f20a69d Books $518.01 76 1.4 98 BULK-f77153e0
5883 Bulk Product 48e99d16 Toys & Games $389.55 438 3.7 0 BULK-b11bdcde
5884 Bulk Product 22a4815e Home & Garden $375.52 236 0.8 19 BULK-960002b6
5885 Bulk Product 8b58f328 Electronics $112.04 150 1.2 71 BULK-54891d77
5886 Bulk Product 0314bb61 Clothing $555.28 163 0.6 38 BULK-0adf4d8a
5887 Bulk Product 38a551fa Clothing $335.88 240 3.1 31 BULK-b5c68533
5888 Bulk Product 335f9e40 Electronics $391.40 222 3.1 98 BULK-e811bade
5889 Bulk Product 5a6686fa Clothing $736.26 389 0.2 66 BULK-f7228567
5890 Bulk Product af490456 Books $236.38 340 2.5 45 BULK-68f619f9
5891 Bulk Product 502ae8f5 Sports & Outdoors $29.22 200 0.9 64 BULK-5bdd43b2
5892 Bulk Product d71c866b Clothing $465.16 307 1.3 36 BULK-a1de2482
5893 Bulk Product 99d78ef6 Electronics $709.41 335 0.7 77 BULK-31248e29
5894 Bulk Product fbdb8796 Books $419.95 80 3.4 55 BULK-010f18d9
5895 Bulk Product a331227c Electronics $314.25 41 2.8 73 BULK-bec13351
5896 Bulk Product d0204e77 Clothing $114.19 227 1.4 35 BULK-c7eb8388
5897 Bulk Product 257b86dc Toys & Games $596.95 408 0.5 16 BULK-e15f158f
5898 Bulk Product 793fc4b7 Electronics $10.33 155 0.8 15 BULK-ca165ffd
5899 Bulk Product 1c1a309c Electronics $391.86 394 3.4 48 BULK-46d3fd1d
5900 Bulk Product f3a15493 Clothing $40.53 185 2.7 56 BULK-e3bef205
5901 Bulk Product 491c9d25 Books $938.96 421 4.8 56 BULK-d1d02aba
5902 Bulk Product 93916406 Toys & Games $688.71 366 2.8 20 BULK-abf1b2c1
5903 Bulk Product eb8de94b Books $931.74 273 0.7 71 BULK-345185d3
5904 Bulk Product db2b8a62 Electronics $471.70 116 4.6 11 BULK-4924b729
5905 Bulk Product db1257eb Books $591.40 247 0.8 47 BULK-2eee7ecd
5906 Bulk Product 1aa81e02 Sports & Outdoors $260.12 304 2.6 11 BULK-2b5f5d78
5907 Bulk Product bb28310e Books $597.30 16 0.5 60 BULK-a803d817
5908 Bulk Product 19ab7eac Sports & Outdoors $424.46 468 1.3 95 BULK-8df004f0
5909 Bulk Product 92c5c9f5 Books $425.61 125 3.0 7 BULK-b2b6dce3
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