Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

87 ms

Page Size

50

Current Page

394 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 394 Results Showing 19651 - 19700 of 24441

ID Name Category Price Stock Rating Reviews SKU
20210 Bulk Product 3bae8afa Clothing $450.77 222 1.9 0 BULK-8bf9dfbf
20211 Bulk Product ddaed4b4 Books $147.74 499 3.5 51 BULK-9d436179
20212 Bulk Product 12fde920 Books $777.17 92 0.1 19 BULK-975a216d
20213 Bulk Product 74430399 Home & Garden $43.54 348 4.7 35 BULK-95db5344
20214 Bulk Product 390f2c2f Books $452.01 151 0.2 44 BULK-1667c424
20215 Bulk Product 12661ed1 Home & Garden $730.03 251 3.4 41 BULK-35daa4bd
20216 Bulk Product 14a0b2e3 Electronics $323.43 42 1.3 4 BULK-5f600e03
20217 Bulk Product ee8897f5 Sports & Outdoors $461.11 122 2.4 94 BULK-c1ed546e
20218 Bulk Product a5454795 Toys & Games $263.84 368 2.8 40 BULK-ae577124
20219 Bulk Product 75093f43 Clothing $513.27 62 2.7 86 BULK-1966d34f
20220 Bulk Product 300e9839 Electronics $321.64 238 0.8 45 BULK-f78ad8b3
20221 Bulk Product e8a825ab Books $116.05 202 1.5 52 BULK-b3ed2019
20222 Bulk Product 7116fb45 Sports & Outdoors $791.10 85 3.9 95 BULK-0993e3e0
20223 Bulk Product b7a94e4c Books $320.46 269 2.7 97 BULK-9380897c
20224 Bulk Product eebaea74 Home & Garden $582.95 342 3.5 11 BULK-b15d634d
20225 Bulk Product 0df9870e Sports & Outdoors $860.40 110 0.9 22 BULK-972f4448
20226 Bulk Product d0a219b4 Books $435.50 433 0.3 81 BULK-c192b608
20227 Bulk Product 362818bd Electronics $60.74 32 3.2 56 BULK-6d015dc3
20228 Bulk Product a497d3a7 Sports & Outdoors $758.11 404 3.8 78 BULK-e5f293b4
20229 Bulk Product f445c99e Clothing $850.41 472 1.1 7 BULK-24ebb0eb
20230 Bulk Product 25882a08 Sports & Outdoors $604.87 80 3.4 68 BULK-8da3c326
20231 Bulk Product 1668b110 Electronics $191.85 387 1.3 65 BULK-7ace41bc
20232 Bulk Product 85f3f023 Electronics $453.85 228 4.9 82 BULK-90bbc590
20233 Bulk Product 930b16d5 Toys & Games $116.72 284 2.0 65 BULK-a2626dfa
20234 Bulk Product 8f685646 Books $619.29 497 2.5 81 BULK-4426bfd6
20235 Bulk Product 96cb965e Electronics $911.01 320 3.1 88 BULK-4cf68e69
20236 Bulk Product eb498b7a Clothing $283.13 5 0.3 67 BULK-b672978e
20237 Bulk Product aca92cbd Clothing $461.18 311 2.8 11 BULK-ed707f33
20238 Bulk Product 9ef5249d Clothing $862.28 265 3.2 49 BULK-6538d6c9
20239 Bulk Product dfb5c3cb Toys & Games $741.06 72 1.8 56 BULK-91a1c281
20240 Bulk Product 96ddd4f8 Home & Garden $24.88 334 3.1 59 BULK-219dcde9
20241 Bulk Product 6efc204d Toys & Games $75.58 9 1.4 19 BULK-030f803e
20242 Bulk Product 521c492e Books $742.28 111 0.4 98 BULK-25fd15fc
20243 Bulk Product 50065269 Sports & Outdoors $369.88 489 1.0 99 BULK-07818b05
20244 Bulk Product 9bf326a3 Books $462.37 294 3.0 51 BULK-4a0bdc0a
20245 Bulk Product 0a8c6697 Books $230.20 148 4.6 93 BULK-74d7b59f
20246 Bulk Product 5e6658d1 Electronics $781.48 103 2.8 39 BULK-454e0bf1
20247 Bulk Product 70be9ff5 Books $363.16 307 1.7 4 BULK-1efa695c
20248 Bulk Product 86fd3473 Books $90.30 430 1.0 60 BULK-7674a40d
20249 Bulk Product e7e81d82 Sports & Outdoors $412.79 211 1.5 18 BULK-34d88d0d
20250 Bulk Product 9d8ff992 Clothing $606.35 63 4.0 40 BULK-23afc0d1
20251 Bulk Product 9270d79c Sports & Outdoors $327.11 321 0.2 72 BULK-ade83627
20252 Bulk Product 5db5eb65 Electronics $879.98 481 4.7 47 BULK-c43a00fb
20253 Bulk Product d390b877 Electronics $117.78 460 2.3 78 BULK-c2851df7
20254 Bulk Product 26be1936 Clothing $191.38 348 2.7 94 BULK-5f752ed1
20255 Bulk Product 9c2631be Clothing $626.71 244 4.1 20 BULK-154ea7af
20256 Bulk Product 9a0153d4 Clothing $135.62 248 2.1 77 BULK-a31012b1
20257 Bulk Product 017fdd4c Sports & Outdoors $843.94 3 4.6 45 BULK-d4aa6edb
20258 Bulk Product 119d2c91 Electronics $514.36 453 2.0 15 BULK-d80b7782
20259 Bulk Product ae711649 Books $601.39 378 4.8 1 BULK-96535081
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