Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

29 ms

Page Size

50

Current Page

452 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 452 Results Showing 22551 - 22600 of 24441

ID Name Category Price Stock Rating Reviews SKU
23110 Bulk Product 73ce76ca Electronics $490.03 482 2.6 6 BULK-37ec2e74
23111 Bulk Product ab44f3e6 Toys & Games $504.13 276 1.9 97 BULK-cf909e08
23112 Bulk Product d6d3c198 Sports & Outdoors $880.70 98 3.0 28 BULK-156d984c
23113 Bulk Product b9e54415 Books $126.50 112 1.7 76 BULK-7ed4de83
23114 Bulk Product 545ca592 Toys & Games $453.69 181 4.6 26 BULK-de55a12e
23115 Bulk Product 0c152c01 Clothing $775.64 103 1.6 77 BULK-92657719
23116 Bulk Product fcdbb290 Clothing $223.16 317 1.9 44 BULK-eff03a86
23117 Bulk Product f719f8fe Home & Garden $999.05 226 2.8 35 BULK-b114b946
23118 Bulk Product 138749a3 Clothing $658.83 433 1.3 10 BULK-b8b081a1
23119 Bulk Product 9a62c391 Electronics $703.94 295 0.3 77 BULK-508186db
23120 Bulk Product 8c5af2c3 Clothing $527.20 9 3.6 17 BULK-4d2cb9c7
23121 Bulk Product 88e98c51 Home & Garden $227.22 382 2.0 23 BULK-69d6e0b1
23122 Bulk Product f8008a4a Clothing $825.44 316 4.0 10 BULK-879c2a95
23123 Bulk Product 5326b560 Books $725.08 407 0.6 58 BULK-fd74a260
23124 Bulk Product 5ace989a Clothing $697.77 258 3.1 39 BULK-1732a6c6
23125 Bulk Product 5cec10db Toys & Games $479.39 346 1.0 43 BULK-c282dba3
23126 Bulk Product 8de0fb36 Electronics $846.84 426 1.3 32 BULK-28d387fe
23127 Bulk Product 30a493ec Electronics $212.39 170 4.5 28 BULK-2205d966
23128 Bulk Product fa22dda2 Books $351.66 198 4.3 94 BULK-f20a40df
23129 Bulk Product 8e873dcd Sports & Outdoors $619.56 59 4.8 32 BULK-0701269d
23130 Bulk Product 8668ae52 Home & Garden $200.94 464 0.9 2 BULK-f07cf071
23131 Bulk Product 0e2b6226 Clothing $489.04 243 2.0 50 BULK-5e93c7d1
23132 Bulk Product 6c138e33 Books $383.43 337 4.0 75 BULK-61ef2e7e
23133 Bulk Product d5510403 Books $72.99 118 2.2 61 BULK-c7396c42
23134 Bulk Product 3dd98267 Electronics $430.68 281 4.7 92 BULK-06bc386d
23135 Bulk Product 02569660 Sports & Outdoors $944.20 293 2.5 19 BULK-7fc6e503
23136 Bulk Product 7f692f90 Books $26.85 38 1.7 3 BULK-37debc49
23137 Bulk Product c63bc55b Sports & Outdoors $157.68 64 1.1 2 BULK-59d48492
23138 Bulk Product 6de9bfde Sports & Outdoors $96.47 226 3.4 39 BULK-77536ec7
23139 Bulk Product 34c879f3 Electronics $384.18 474 1.9 59 BULK-5ea8abed
23140 Bulk Product 94104bac Clothing $29.20 269 5.0 53 BULK-b741468f
23141 Bulk Product b62df384 Toys & Games $183.83 189 0.0 10 BULK-73ac60c2
23142 Bulk Product eca8cf80 Sports & Outdoors $573.20 18 4.2 14 BULK-fca19e42
23143 Bulk Product e7e91e3c Toys & Games $367.91 206 2.5 31 BULK-807a31da
23144 Bulk Product d2294ba2 Books $432.82 126 1.8 81 BULK-b58f2691
23145 Bulk Product a4fe669b Sports & Outdoors $491.13 44 4.1 34 BULK-c8eba057
23146 Bulk Product cc001d0d Clothing $167.07 70 3.7 17 BULK-d5ca9e5d
23147 Bulk Product c8953ce3 Books $885.60 192 5.0 96 BULK-33bdd3d4
23148 Bulk Product abaa9ebc Books $661.92 429 4.4 43 BULK-60b3a068
23149 Bulk Product 68b61c88 Toys & Games $845.49 292 4.6 26 BULK-ea51e120
23150 Bulk Product 1d50277c Electronics $220.85 126 2.5 35 BULK-13261e83
23151 Bulk Product 6ba8d731 Toys & Games $705.39 465 4.9 9 BULK-b15041c2
23152 Bulk Product 8890651f Home & Garden $286.29 260 4.1 50 BULK-56992dfd
23153 Bulk Product ebaa1458 Sports & Outdoors $503.75 377 0.6 90 BULK-e21630a9
23154 Bulk Product 81e135b4 Toys & Games $376.49 321 3.0 45 BULK-763516e2
23155 Bulk Product 36b5255a Sports & Outdoors $66.54 180 4.7 47 BULK-3c2010d9
23156 Bulk Product 7ff4e4ba Clothing $539.51 441 5.0 37 BULK-fa1a9642
23157 Bulk Product cc7bdee0 Books $569.42 162 2.3 76 BULK-eddb7b4d
23158 Bulk Product f462d41b Electronics $170.11 280 1.5 75 BULK-885eb68c
23159 Bulk Product 845cd0a6 Clothing $447.23 241 0.5 85 BULK-3100754b
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