Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

25 ms

Page Size

50

Current Page

355 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 355 Results Showing 17701 - 17750 of 24441

ID Name Category Price Stock Rating Reviews SKU
18260 Bulk Product 2594b2db Electronics $821.76 241 1.0 75 BULK-0fc55b4c
18261 Bulk Product 97344815 Home & Garden $534.81 208 4.9 66 BULK-1e380e62
18262 Bulk Product 3c741ca5 Books $678.89 348 3.5 69 BULK-8c1b5e6e
18263 Bulk Product 2bdd334b Toys & Games $151.53 375 4.1 77 BULK-bb2a2869
18264 Bulk Product ce5d5503 Sports & Outdoors $535.92 107 2.0 11 BULK-a758f70c
18265 Bulk Product 7099e731 Electronics $213.56 402 4.0 21 BULK-aa0cb176
18266 Bulk Product dc51a180 Clothing $20.47 134 4.0 5 BULK-36d37eb9
18267 Bulk Product 07d02512 Electronics $381.47 112 1.6 95 BULK-a4525ca2
18268 Bulk Product 50242fde Electronics $880.73 376 0.8 34 BULK-d864a488
18269 Bulk Product 2bf7243c Toys & Games $301.14 141 3.7 60 BULK-4390ee34
18270 Bulk Product a79b5855 Sports & Outdoors $463.41 79 4.4 35 BULK-bdede83a
18271 Bulk Product 9d96a7dc Electronics $260.23 293 4.6 12 BULK-4bec14a8
18272 Bulk Product 0c6b41e7 Clothing $396.18 3 1.0 15 BULK-9a072a80
18273 Bulk Product e85756dd Toys & Games $71.21 416 4.6 54 BULK-c1876261
18274 Bulk Product d675d46b Toys & Games $973.62 359 0.1 31 BULK-448fddd5
18275 Bulk Product c5ba8c01 Sports & Outdoors $1,000.31 453 1.7 24 BULK-e4cd185b
18276 Bulk Product 6abca393 Sports & Outdoors $760.35 9 2.3 93 BULK-aedc566f
18277 Bulk Product ed0f8707 Sports & Outdoors $608.30 56 3.0 27 BULK-07fc3307
18278 Bulk Product 00dc3b5a Books $407.07 245 0.1 56 BULK-edb813d2
18279 Bulk Product a192cf02 Clothing $38.00 357 3.5 12 BULK-44e2d0ae
18280 Bulk Product b89e12b8 Sports & Outdoors $883.37 116 3.0 28 BULK-ea088b18
18281 Bulk Product 3f27e813 Toys & Games $357.98 188 0.2 9 BULK-170c415e
18282 Bulk Product 16477f22 Electronics $615.09 285 0.1 50 BULK-8fa40648
18283 Bulk Product 4422ca90 Clothing $513.67 406 3.0 95 BULK-c6b81ab4
18284 Bulk Product faf0511d Home & Garden $789.19 379 1.9 70 BULK-93f45906
18285 Bulk Product 4df4dd4d Clothing $407.32 49 3.2 29 BULK-07f9f2c3
18286 Bulk Product 493b5548 Electronics $994.42 242 4.8 89 BULK-6e888fd3
18287 Bulk Product 713ab995 Clothing $62.59 419 1.9 89 BULK-cc11d8c2
18288 Bulk Product abdff5f0 Sports & Outdoors $174.18 291 0.2 98 BULK-2ea34403
18289 Bulk Product 0f9aeef6 Toys & Games $556.13 389 3.6 46 BULK-72fc05fc
18290 Bulk Product 2afe1e43 Home & Garden $203.13 209 3.1 53 BULK-dc2be9d0
18291 Bulk Product a69e1dc1 Books $687.72 319 0.0 67 BULK-5bf9d6e6
18292 Bulk Product 17ec4691 Home & Garden $595.38 125 1.8 83 BULK-b24d09bc
18293 Bulk Product 37921ac0 Sports & Outdoors $690.70 211 3.2 40 BULK-6e4c308f
18294 Bulk Product a943afeb Clothing $744.42 159 1.0 34 BULK-6b237165
18295 Bulk Product 7e1a7186 Books $596.05 83 1.9 44 BULK-a88e2dd7
18296 Bulk Product d5d151ec Books $92.53 468 1.2 85 BULK-49549c2e
18297 Bulk Product 9ba60c18 Books $745.37 460 3.3 99 BULK-a4706332
18298 Bulk Product e542cbb2 Toys & Games $481.18 297 3.0 91 BULK-48ff3dc4
18299 Bulk Product 1eb8db43 Home & Garden $65.15 129 1.2 31 BULK-54534776
18300 Bulk Product b8c5192f Sports & Outdoors $421.40 197 0.2 42 BULK-4c8a64e1
18301 Bulk Product 16f9d8c4 Home & Garden $285.98 488 2.1 22 BULK-3ff2343b
18302 Bulk Product 68034a86 Electronics $57.89 347 0.7 85 BULK-97cc9f09
18303 Bulk Product 2ca4a5fb Electronics $227.56 477 1.7 22 BULK-8188de1a
18304 Bulk Product c321cbef Electronics $837.05 113 3.9 84 BULK-3deea1e0
18305 Bulk Product 24df0e57 Sports & Outdoors $24.56 25 1.4 27 BULK-6fd3f138
18306 Bulk Product 118d7d71 Clothing $342.04 279 4.1 86 BULK-330ea4a8
18307 Bulk Product 0740c1b5 Clothing $819.43 110 1.5 78 BULK-96c916ad
18308 Bulk Product f2014996 Clothing $801.65 365 2.3 63 BULK-18f1b3a3
18309 Bulk Product 8de1f29f Books $884.59 181 0.9 45 BULK-bd6a65a7
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