Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

16 ms

Page Size

50

Current Page

275 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 275 Results Showing 13701 - 13750 of 24441

ID Name Category Price Stock Rating Reviews SKU
14260 Bulk Product 40cabeba Toys & Games $994.26 327 2.7 26 BULK-948fff0e
14261 Bulk Product c9c208eb Electronics $32.72 139 0.6 48 BULK-a6defb54
14262 Bulk Product 755e5b2f Electronics $372.26 495 4.0 81 BULK-6745fbd0
14263 Bulk Product 5f7d9ae0 Home & Garden $188.42 176 0.8 88 BULK-9ddf3a15
14264 Bulk Product 2bee970d Toys & Games $533.80 307 2.5 48 BULK-e0a6022a
14265 Bulk Product 44b030ff Clothing $148.23 166 1.3 89 BULK-6a4cca8d
14266 Bulk Product ee40cc1d Sports & Outdoors $423.35 333 1.7 33 BULK-b7c90fb3
14267 Bulk Product 144134c3 Clothing $235.36 377 4.3 7 BULK-17809990
14268 Bulk Product da23c0c3 Books $637.49 144 2.5 53 BULK-3c964d6a
14269 Bulk Product 34603927 Sports & Outdoors $571.21 140 2.5 27 BULK-0fb30b5f
14270 Bulk Product c3271d41 Electronics $147.99 350 3.6 22 BULK-470a972e
14271 Bulk Product d3cb6f25 Books $563.50 146 3.3 96 BULK-14f3b075
14272 Bulk Product 6a1f221d Sports & Outdoors $119.99 80 3.7 65 BULK-f8e3d4c3
14273 Bulk Product 7adaf32c Electronics $702.52 61 1.7 93 BULK-373f2271
14274 Bulk Product 54612f77 Sports & Outdoors $889.76 154 3.9 65 BULK-8317aca4
14275 Bulk Product cb17d398 Clothing $594.17 119 0.1 98 BULK-7ac32c1a
14276 Bulk Product 90ede055 Clothing $430.52 244 4.4 63 BULK-8234eb02
14277 Bulk Product d37b581d Sports & Outdoors $437.03 381 4.4 39 BULK-a132dd6a
14278 Bulk Product 445a6deb Toys & Games $146.25 162 4.8 97 BULK-a2c23375
14279 Bulk Product f7a0e0a2 Clothing $290.62 234 3.6 63 BULK-e1c40c2b
14280 Bulk Product 34c1ce71 Sports & Outdoors $711.11 290 3.4 62 BULK-3e70c759
14281 Bulk Product 40895c11 Home & Garden $515.62 376 0.5 22 BULK-70241d70
14282 Bulk Product fef657d2 Electronics $547.91 283 1.0 2 BULK-c06d622c
14283 Bulk Product ed09dabf Sports & Outdoors $147.41 256 2.9 83 BULK-5f7a7528
14284 Bulk Product 31c13237 Home & Garden $455.32 376 1.0 71 BULK-c9c6c11b
14285 Bulk Product 16e1d187 Electronics $758.05 298 0.9 26 BULK-9e443028
14286 Bulk Product d1712e28 Toys & Games $1,003.73 418 4.6 33 BULK-ebd70f33
14287 Bulk Product f0cf04d0 Electronics $89.17 372 2.1 66 BULK-0411460f
14288 Bulk Product 6123db4b Sports & Outdoors $578.47 78 1.7 51 BULK-b68a647b
14289 Bulk Product 96860b7f Clothing $23.96 492 0.3 6 BULK-969f83b4
14290 Bulk Product 694126c0 Electronics $60.28 466 2.0 91 BULK-ed53af12
14291 Bulk Product 07049741 Books $558.83 102 5.0 41 BULK-166cd1bc
14292 Bulk Product 4da2600f Home & Garden $883.24 429 2.8 33 BULK-9b586e02
14293 Bulk Product 9626db98 Clothing $570.61 50 0.1 9 BULK-825ad00f
14294 Bulk Product 7f6c7783 Toys & Games $441.08 249 3.4 71 BULK-9ecbe0e5
14295 Bulk Product 7d8bd1df Toys & Games $321.41 244 4.3 47 BULK-a7d99a5e
14296 Bulk Product 53925128 Books $129.99 496 1.7 67 BULK-0a2c1bd3
14297 Bulk Product ae74d34e Electronics $328.79 364 2.7 54 BULK-0e42b68f
14298 Bulk Product 6c9a3c4e Toys & Games $980.05 23 1.4 92 BULK-80b23ac6
14299 Bulk Product 2a397e5f Sports & Outdoors $716.72 27 1.6 87 BULK-84f42d0d
14300 Bulk Product f5e63e23 Toys & Games $900.37 400 3.7 29 BULK-f724f723
14301 Bulk Product f8e53ff4 Clothing $456.04 449 0.2 78 BULK-91f7e813
14302 Bulk Product a9953c74 Toys & Games $1,008.17 148 1.7 63 BULK-04ee0eab
14303 Bulk Product 44b4d108 Electronics $259.91 60 3.6 31 BULK-9c3e8a44
14304 Bulk Product 3b4540ba Toys & Games $463.59 299 3.7 35 BULK-69b09d98
14305 Bulk Product a739832c Electronics $280.99 39 3.0 11 BULK-d518a0c0
14306 Bulk Product e45e5977 Toys & Games $20.93 360 1.2 98 BULK-af7e3a27
14307 Bulk Product 7c1f6b82 Electronics $247.89 397 2.1 42 BULK-5c386d26
14308 Bulk Product c3e259b5 Books $103.16 172 2.5 98 BULK-9a0e3717
14309 Bulk Product b6c34659 Home & Garden $792.26 254 2.4 96 BULK-56a2536a
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