Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

16 ms

Page Size

50

Current Page

259 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 259 Results Showing 12901 - 12950 of 24441

ID Name Category Price Stock Rating Reviews SKU
13460 Bulk Product 9f0b6496 Electronics $74.17 168 1.6 84 BULK-f31bbe41
13461 Bulk Product e0c8ee5b Sports & Outdoors $160.70 280 4.8 36 BULK-8dab21db
13462 Bulk Product 05ab2532 Home & Garden $719.73 337 0.4 84 BULK-ab103c48
13463 Bulk Product 8eda690e Books $892.57 235 3.9 65 BULK-23da4f9e
13464 Bulk Product 0aa54731 Clothing $75.59 156 2.1 56 BULK-9303fc7c
13465 Bulk Product 17bda66e Clothing $576.71 472 1.7 42 BULK-4060ddd8
13466 Bulk Product bda8e149 Electronics $357.02 489 3.1 54 BULK-18128ee8
13467 Bulk Product 81256204 Electronics $185.36 497 1.7 67 BULK-fb291e05
13468 Bulk Product fd362e2c Sports & Outdoors $290.86 186 4.2 6 BULK-56e27950
13469 Bulk Product e819b69b Sports & Outdoors $975.16 429 1.8 7 BULK-0b65f9a4
13470 Bulk Product 3a37cc8b Sports & Outdoors $504.87 270 4.5 64 BULK-d7289627
13471 Bulk Product 3a5c1db2 Home & Garden $582.11 293 2.7 1 BULK-50648545
13472 Bulk Product f1b499d2 Sports & Outdoors $574.96 264 4.1 85 BULK-a179dde7
13473 Bulk Product 350dd1da Sports & Outdoors $960.79 307 2.5 78 BULK-4c7f5791
13474 Bulk Product 233b69a4 Electronics $717.85 373 4.9 89 BULK-e3313766
13475 Bulk Product 8ced5b8d Electronics $500.97 417 2.8 77 BULK-8411a784
13476 Bulk Product 676c4e90 Electronics $107.11 100 2.3 46 BULK-40748710
13477 Bulk Product 105813c2 Electronics $522.70 398 1.7 97 BULK-3879e06e
13478 Bulk Product 3f04c433 Home & Garden $956.77 99 1.7 77 BULK-3ac01cda
13479 Bulk Product 6db0b3d9 Electronics $373.16 499 2.3 4 BULK-713e852e
13480 Bulk Product a43ecb27 Toys & Games $1,004.43 92 1.9 81 BULK-209af744
13481 Bulk Product 2aef411d Sports & Outdoors $229.87 185 4.7 82 BULK-70eeb679
13482 Bulk Product 84f4ddca Home & Garden $367.98 331 1.1 24 BULK-7b9d3f9e
13483 Bulk Product 9ae98314 Books $326.03 207 1.7 27 BULK-de2d4cfc
13484 Bulk Product f1985a0d Toys & Games $998.79 396 0.2 18 BULK-c9785128
13485 Bulk Product 7848e78b Toys & Games $865.37 383 3.8 66 BULK-60cb198f
13486 Bulk Product 26440c8b Electronics $155.73 329 2.2 99 BULK-451ea422
13487 Bulk Product a643dc0f Clothing $297.27 258 3.6 46 BULK-e64fa538
13488 Bulk Product 62c3fa7c Books $758.11 350 3.5 27 BULK-9ddeccf2
13489 Bulk Product 83a10762 Sports & Outdoors $988.23 177 3.1 64 BULK-8307959a
13490 Bulk Product f8c28a9a Electronics $107.44 182 1.3 53 BULK-ec5a1677
13491 Bulk Product 041464c3 Home & Garden $66.65 270 4.0 35 BULK-970f0140
13492 Bulk Product 2c71fc14 Books $263.79 199 2.2 61 BULK-596c466c
13493 Bulk Product 03179631 Sports & Outdoors $872.65 145 1.3 35 BULK-3cb9e5e3
13494 Bulk Product 401e7401 Electronics $932.50 480 0.1 78 BULK-3b3bdea5
13495 Bulk Product 5d259770 Toys & Games $224.61 158 1.3 24 BULK-99685298
13496 Bulk Product 3d4e859e Toys & Games $186.43 82 2.3 2 BULK-a059e9c9
13497 Bulk Product 9193156a Sports & Outdoors $216.68 334 1.7 39 BULK-71da00ad
13498 Bulk Product ffa01eea Sports & Outdoors $549.95 168 3.4 87 BULK-862b76c9
13499 Bulk Product ac894dbf Electronics $593.83 61 4.8 99 BULK-88ca13f7
13500 Bulk Product d4363e68 Books $496.82 399 2.6 33 BULK-c8fcefb1
13501 Bulk Product 1458e696 Clothing $874.63 129 3.6 14 BULK-55ba7514
13502 Bulk Product 5796c8ed Clothing $542.09 100 4.9 43 BULK-5a69e188
13503 Bulk Product 45369a49 Sports & Outdoors $456.86 140 1.7 69 BULK-5d77694d
13504 Bulk Product 13d6cec8 Books $226.81 51 0.9 13 BULK-ddfeaebf
13505 Bulk Product d284f390 Clothing $412.70 345 0.4 98 BULK-da8e0178
13506 Bulk Product 56be4f42 Electronics $107.44 242 2.5 43 BULK-0c47ee38
13507 Bulk Product 340a98ba Books $84.65 216 3.6 55 BULK-0b2b92d7
13508 Bulk Product 57c30e32 Toys & Games $652.47 479 2.2 50 BULK-6010a6ae
13509 Bulk Product 46146989 Home & Garden $942.56 4 0.3 8 BULK-6077462a
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