Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

13 ms

Page Size

50

Current Page

297 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 297 Results Showing 14801 - 14850 of 24441

ID Name Category Price Stock Rating Reviews SKU
15360 Bulk Product 30907438 Books $840.27 414 1.2 12 BULK-464ec273
15361 Bulk Product e93535e9 Sports & Outdoors $248.29 138 2.2 81 BULK-8e706893
15362 Bulk Product d33d39d3 Books $343.63 387 2.4 20 BULK-e1dc2477
15363 Bulk Product ea9b713a Books $943.69 10 2.3 67 BULK-78e72bc5
15364 Bulk Product 8f47d9b1 Sports & Outdoors $60.32 304 3.4 73 BULK-7e9f17d7
15365 Bulk Product a6a2b53d Clothing $641.17 188 0.4 88 BULK-3ddf6cbe
15366 Bulk Product 91bfc514 Clothing $770.30 438 2.5 15 BULK-32031bb3
15367 Bulk Product 244bc963 Electronics $316.13 404 1.2 84 BULK-9ed21a7b
15368 Bulk Product 146260b5 Home & Garden $532.28 279 3.8 32 BULK-dbae15c4
15369 Bulk Product a5337156 Sports & Outdoors $881.97 379 0.9 57 BULK-addde117
15370 Bulk Product 6f88a6a3 Sports & Outdoors $881.51 247 4.2 22 BULK-c7b2540b
15371 Bulk Product 8b892e61 Electronics $27.18 9 2.4 24 BULK-2825c4c8
15372 Bulk Product d9f17d70 Home & Garden $243.73 380 0.6 21 BULK-684fd82d
15373 Bulk Product 2741db9c Electronics $327.77 364 3.9 96 BULK-e9e7a1a9
15374 Bulk Product a0556627 Toys & Games $269.66 257 2.0 11 BULK-fedb70a8
15375 Bulk Product 510c6032 Electronics $750.13 271 3.9 79 BULK-ed8031f1
15376 Bulk Product 500a8897 Home & Garden $807.90 194 1.5 88 BULK-bd1adac2
15377 Bulk Product f5b28abb Clothing $807.55 328 3.5 29 BULK-750d2088
15378 Bulk Product e99989ba Toys & Games $40.88 309 2.6 75 BULK-f7a55527
15379 Bulk Product f48805ab Clothing $698.21 129 3.6 86 BULK-ec5ba211
15380 Bulk Product bdb56c40 Sports & Outdoors $828.69 235 2.3 37 BULK-622b9124
15381 Bulk Product 77018be6 Toys & Games $1,009.65 419 4.0 85 BULK-f8b472cf
15382 Bulk Product 5aff719e Clothing $467.55 196 1.2 61 BULK-5fa4d358
15383 Bulk Product cd5a144b Clothing $891.16 266 0.2 87 BULK-2600ec20
15384 Bulk Product c5e64993 Home & Garden $280.56 369 2.1 51 BULK-982ac631
15385 Bulk Product f21ec43b Sports & Outdoors $658.40 50 2.1 16 BULK-84108125
15386 Bulk Product 5e7b1fdc Home & Garden $865.81 348 4.9 2 BULK-aa083d9b
15387 Bulk Product 4ebe0aee Home & Garden $187.84 110 1.7 21 BULK-60104b4d
15388 Bulk Product 25a99ae4 Toys & Games $555.66 496 0.5 31 BULK-ed832ba6
15389 Bulk Product d9452c2d Toys & Games $163.78 210 1.5 96 BULK-30a7ae3c
15390 Bulk Product 7b7843a7 Sports & Outdoors $201.32 63 0.8 46 BULK-ab7609a0
15391 Bulk Product a73271c6 Toys & Games $264.38 488 2.5 1 BULK-2d399918
15392 Bulk Product 783f221c Clothing $570.51 32 2.9 60 BULK-fa459e85
15393 Bulk Product 93b5fa71 Clothing $58.82 361 0.6 87 BULK-49127ccd
15394 Bulk Product 46ee2564 Books $17.05 102 1.5 58 BULK-27e359e7
15395 Bulk Product 49579f68 Electronics $719.73 29 3.0 46 BULK-903e48ca
15396 Bulk Product c0aed4fc Clothing $504.66 320 0.3 89 BULK-2b27b7c2
15397 Bulk Product 58bc9ed9 Toys & Games $790.04 158 3.3 52 BULK-01e7c2c0
15398 Bulk Product fda5cf05 Sports & Outdoors $958.28 286 4.6 59 BULK-5006b102
15399 Bulk Product 3ce2f00a Clothing $832.28 490 4.5 32 BULK-1a550f7c
15400 Bulk Product 8faace0f Sports & Outdoors $187.21 130 0.9 24 BULK-eb9001fd
15401 Bulk Product 91c08c9b Books $413.07 413 1.0 59 BULK-c3b930de
15402 Bulk Product 767c3496 Toys & Games $85.59 245 3.2 93 BULK-c3a943a4
15403 Bulk Product 96c96042 Sports & Outdoors $549.12 401 0.8 14 BULK-145eb670
15404 Bulk Product 16a12e5a Electronics $965.43 382 1.5 39 BULK-3066f5ac
15405 Bulk Product ee4b2f63 Sports & Outdoors $496.24 388 4.4 46 BULK-b63797fe
15406 Bulk Product 5931db8b Home & Garden $586.95 337 1.5 88 BULK-0624248b
15407 Bulk Product 14ac95fb Toys & Games $661.45 31 4.8 95 BULK-28f4128e
15408 Bulk Product 8f2cd5fb Books $233.89 458 2.7 89 BULK-3f35665c
15409 Bulk Product df801d6b Electronics $140.45 371 1.9 46 BULK-bffa593d
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