Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

107 ms

Page Size

50

Current Page

117 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 117 Results Showing 5801 - 5850 of 24441

ID Name Category Price Stock Rating Reviews SKU
6360 Bulk Product 625c2368 Clothing $641.30 102 2.6 75 BULK-08b2952d
6361 Bulk Product fea80663 Electronics $344.75 85 4.5 16 BULK-876aaecb
6362 Bulk Product 2cfe0a80 Toys & Games $303.97 210 4.1 78 BULK-fe84732a
6363 Bulk Product 32d6a9ad Clothing $845.29 328 1.0 43 BULK-c4f8e5e4
6364 Bulk Product 2dc59172 Sports & Outdoors $394.22 388 0.7 48 BULK-f7f61fdc
6365 Bulk Product 14747eed Books $301.00 69 3.9 27 BULK-ca2fffc0
6366 Bulk Product a371e2a4 Electronics $507.04 141 0.0 49 BULK-46b97723
6367 Bulk Product fb939757 Books $194.01 129 1.1 30 BULK-c0065a1c
6368 Bulk Product 1d82fe25 Clothing $967.64 395 4.0 70 BULK-f7dbb5e2
6369 Bulk Product eff32515 Books $756.70 13 0.3 10 BULK-4d876b25
6370 Bulk Product 35ce77fd Toys & Games $601.48 300 1.2 67 BULK-f0ef9f92
6371 Bulk Product e182073f Books $976.39 142 2.4 10 BULK-5a34c928
6372 Bulk Product d6b09a34 Books $875.65 146 2.4 31 BULK-f2ed4cd4
6373 Bulk Product 292ddc71 Electronics $101.44 195 2.9 74 BULK-df8557a0
6374 Bulk Product bce8d44e Clothing $357.19 446 1.9 6 BULK-05c20833
6375 Bulk Product c44736aa Electronics $765.52 408 4.1 64 BULK-c06e9f30
6376 Bulk Product 39365d4a Clothing $758.75 134 1.1 28 BULK-052cbce1
6377 Bulk Product fac7a201 Books $995.93 478 0.3 57 BULK-bbec2d7b
6378 Bulk Product e26d40b5 Electronics $521.08 206 0.6 85 BULK-ff086b79
6379 Bulk Product 075de188 Clothing $521.63 485 3.8 71 BULK-9e3e1d83
6380 Bulk Product 2d141954 Home & Garden $626.38 40 2.2 58 BULK-e6724930
6381 Bulk Product 49f0b53d Books $113.03 367 4.7 37 BULK-f75cbe6b
6382 Bulk Product 2a547ad8 Books $159.48 83 4.6 97 BULK-0be38863
6383 Bulk Product 28534cbe Electronics $73.09 455 2.5 62 BULK-3b3261ce
6384 Bulk Product b7772872 Toys & Games $133.51 416 0.2 43 BULK-55895256
6385 Bulk Product 8e913841 Toys & Games $186.35 356 4.8 67 BULK-59d735bd
6386 Bulk Product fcdedca2 Home & Garden $937.92 51 0.8 72 BULK-bfba7bf6
6387 Bulk Product defe85b9 Toys & Games $758.11 431 1.4 51 BULK-92c1b122
6388 Bulk Product 1ef4766f Electronics $660.02 126 4.0 48 BULK-2306614f
6389 Bulk Product f795ac26 Toys & Games $834.70 365 4.4 4 BULK-0b55cdf0
6390 Bulk Product ddddac30 Clothing $591.82 343 2.2 45 BULK-66ca4a19
6391 Bulk Product 562923e1 Books $190.86 329 4.4 19 BULK-1b46d9bc
6392 Bulk Product 3b78d24b Clothing $817.39 320 1.3 28 BULK-09e9aa38
6393 Bulk Product 0b50eb8b Sports & Outdoors $333.61 422 0.1 23 BULK-58fefda6
6394 Bulk Product ff817a02 Home & Garden $786.56 163 2.6 6 BULK-75b432d3
6395 Bulk Product ad155264 Home & Garden $58.04 110 4.9 79 BULK-c4d8096a
6396 Bulk Product ac6bb655 Home & Garden $798.09 119 1.8 20 BULK-e0e7fb06
6397 Bulk Product cb26aac3 Electronics $572.77 87 2.6 92 BULK-66cad410
6398 Bulk Product da089472 Toys & Games $659.80 139 2.4 79 BULK-42e03af2
6399 Bulk Product 1d95c134 Books $238.92 264 1.5 64 BULK-3aef4ecb
6400 Bulk Product b124c4cc Books $863.86 402 1.9 67 BULK-3e6ddb48
6401 Bulk Product 0609d24a Home & Garden $587.58 412 4.7 6 BULK-e95b927d
6402 Bulk Product 12a4ffeb Toys & Games $476.02 208 0.3 51 BULK-5b9edd72
6403 Bulk Product 499daecd Toys & Games $45.53 279 1.0 38 BULK-ae60e98c
6404 Bulk Product beea7b9f Home & Garden $691.50 65 2.5 86 BULK-4733108d
6405 Bulk Product befb5b2e Toys & Games $394.23 146 1.4 27 BULK-61e30b25
6406 Bulk Product 39808c31 Books $978.24 335 3.8 52 BULK-408ec9ee
6407 Bulk Product 66729242 Home & Garden $725.64 435 0.0 19 BULK-d73f0aa4
6408 Bulk Product bb333760 Toys & Games $308.64 242 1.0 91 BULK-46b03187
6409 Bulk Product e2d4e6b1 Home & Garden $30.89 85 0.7 10 BULK-b10449df
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