Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

21 ms

Page Size

50

Current Page

455 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 455 Results Showing 22701 - 22750 of 24441

ID Name Category Price Stock Rating Reviews SKU
23260 Bulk Product a93e4162 Sports & Outdoors $952.57 45 0.8 76 BULK-49c83814
23261 Bulk Product 6113a674 Books $956.65 328 3.6 90 BULK-45768a70
23262 Bulk Product 28f3fcd9 Electronics $423.43 302 3.5 36 BULK-6a3a1a9e
23263 Bulk Product fd699cf2 Books $241.33 414 4.4 38 BULK-d6701b1a
23264 Bulk Product 9a3fdd5d Books $926.56 249 2.2 8 BULK-29a1dc66
23265 Bulk Product 3fbe4d38 Sports & Outdoors $235.56 201 4.7 16 BULK-4d8fee07
23266 Bulk Product 4dc847eb Sports & Outdoors $426.06 203 1.5 6 BULK-325cc041
23267 Bulk Product 67a176c9 Clothing $509.81 147 3.1 92 BULK-221efba5
23268 Bulk Product 724fa626 Home & Garden $902.51 369 1.0 13 BULK-21287613
23269 Bulk Product 0e7b1583 Books $769.79 159 2.1 84 BULK-386f3b8f
23270 Bulk Product 864cfa0d Books $62.21 152 0.0 78 BULK-04227bef
23271 Bulk Product d2add85b Toys & Games $969.69 419 1.4 71 BULK-adb1fc88
23272 Bulk Product 98d13188 Electronics $604.18 499 4.4 63 BULK-316c6dea
23273 Bulk Product 99f2bc7f Toys & Games $737.85 483 2.5 80 BULK-d289d67e
23274 Bulk Product 0c68d5ef Home & Garden $243.04 51 1.3 47 BULK-4b537923
23275 Bulk Product d8689c72 Sports & Outdoors $34.46 285 4.0 53 BULK-4faa1707
23276 Bulk Product 7892225f Toys & Games $786.45 137 4.9 95 BULK-68a9f965
23277 Bulk Product 186dc404 Sports & Outdoors $708.37 254 0.7 56 BULK-2e9f62ee
23278 Bulk Product 725cb5ea Home & Garden $798.95 138 4.6 42 BULK-62af7c89
23279 Bulk Product 0c1e346d Home & Garden $386.00 18 1.4 10 BULK-d64a4e34
23280 Bulk Product 39b233ac Home & Garden $301.61 343 1.5 83 BULK-e3abe5f2
23281 Bulk Product b0eb82eb Sports & Outdoors $734.81 150 5.0 4 BULK-bb719462
23282 Bulk Product b2f1b418 Clothing $222.32 295 2.2 8 BULK-1a73ea6d
23283 Bulk Product bcfb7d05 Sports & Outdoors $783.28 184 0.7 63 BULK-c38ec300
23284 Bulk Product 04f78a4d Electronics $641.99 144 2.6 18 BULK-53a8b8e4
23285 Bulk Product a6576c8b Toys & Games $327.21 11 4.4 8 BULK-d1883006
23286 Bulk Product 48893234 Books $236.64 153 2.8 21 BULK-af340445
23287 Bulk Product a83fb0fc Sports & Outdoors $576.21 282 2.9 59 BULK-ecc4a9d4
23288 Bulk Product a83821a9 Toys & Games $239.24 167 3.7 13 BULK-e56f06d7
23289 Bulk Product 3e9b895b Books $110.10 317 1.6 95 BULK-f49d5a9f
23290 Bulk Product c5c68a80 Home & Garden $353.39 482 3.6 47 BULK-3dca51d6
23291 Bulk Product 659d9c29 Books $208.16 202 1.0 9 BULK-09f8a687
23292 Bulk Product 132cf8dd Sports & Outdoors $34.66 13 1.8 44 BULK-47126e9e
23293 Bulk Product 564d5dc6 Clothing $411.29 411 2.0 48 BULK-d7cc543a
23294 Bulk Product 9cd67804 Sports & Outdoors $807.70 258 1.8 36 BULK-2d06c588
23295 Bulk Product 1e609da8 Clothing $265.41 308 3.6 62 BULK-523a2352
23296 Bulk Product b598a4ae Electronics $477.67 8 4.7 46 BULK-a76449ba
23297 Bulk Product d0a5a082 Toys & Games $113.16 310 4.1 28 BULK-8cc2f44a
23298 Bulk Product b125ebfe Toys & Games $566.12 346 2.4 64 BULK-52e1d3f6
23299 Bulk Product 87343733 Home & Garden $919.25 102 3.9 5 BULK-17570821
23300 Bulk Product 93efb1da Sports & Outdoors $21.61 18 3.4 43 BULK-5b0cac5a
23301 Bulk Product ef939f99 Clothing $562.84 432 0.7 25 BULK-78ef8284
23302 Bulk Product b80801ca Books $595.84 149 4.7 28 BULK-a012e79b
23303 Bulk Product 74e64d83 Toys & Games $613.29 147 0.6 60 BULK-51db5730
23304 Bulk Product f5f98c23 Sports & Outdoors $146.58 292 2.0 74 BULK-142ecc2b
23305 Bulk Product ba8a45e5 Electronics $629.74 388 1.2 78 BULK-832cab01
23306 Bulk Product 808e5c4e Electronics $933.35 122 4.4 32 BULK-8a74a8bf
23307 Bulk Product 9f940512 Books $133.23 140 3.0 2 BULK-05cff44a
23308 Bulk Product 913f5a6a Clothing $599.65 291 4.8 4 BULK-a4ecfcf7
23309 Bulk Product 7373085b Sports & Outdoors $141.75 492 1.9 69 BULK-f1e6f170
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