Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

20 ms

Page Size

50

Current Page

315 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 315 Results Showing 15701 - 15750 of 24441

ID Name Category Price Stock Rating Reviews SKU
16260 Bulk Product 8b1dc07d Clothing $321.45 350 4.7 67 BULK-32ca002a
16261 Bulk Product a761619c Home & Garden $52.03 160 3.6 68 BULK-496f06f7
16262 Bulk Product 41c9567a Toys & Games $672.55 490 2.6 11 BULK-a1fb58fd
16263 Bulk Product 96524c95 Home & Garden $343.79 467 2.7 70 BULK-5e37613f
16264 Bulk Product a543c608 Sports & Outdoors $681.47 235 3.8 94 BULK-b894e2c6
16265 Bulk Product 8df66bce Books $829.98 455 2.7 35 BULK-050497c1
16266 Bulk Product 7fd37c2a Home & Garden $877.76 393 4.6 61 BULK-6a4579cd
16267 Bulk Product 2e78605f Books $977.21 353 0.0 23 BULK-63bbeb10
16268 Bulk Product 76de0454 Sports & Outdoors $917.34 445 3.9 33 BULK-9108845f
16269 Bulk Product 27815715 Home & Garden $521.20 352 2.9 62 BULK-70821e8a
16270 Bulk Product 26ba032c Sports & Outdoors $425.83 369 4.9 75 BULK-0b385f83
16271 Bulk Product 3c8ecef5 Home & Garden $345.87 178 3.3 57 BULK-52651991
16272 Bulk Product ef57dd9d Electronics $908.40 344 3.0 6 BULK-4bcbf907
16273 Bulk Product af6026e4 Electronics $346.83 282 3.1 56 BULK-3c437248
16274 Bulk Product 1fe17731 Clothing $87.31 181 3.5 19 BULK-4065176d
16275 Bulk Product 3fb81c06 Toys & Games $224.44 407 0.9 43 BULK-d2caa3b0
16276 Bulk Product bd591e96 Electronics $875.87 421 4.3 97 BULK-5bdf2af9
16277 Bulk Product fd69dee9 Electronics $390.90 437 0.8 10 BULK-06221eab
16278 Bulk Product 24dd62b2 Home & Garden $813.43 263 0.2 47 BULK-85528bdb
16279 Bulk Product d84ba002 Books $779.52 223 2.1 76 BULK-b5cc4fd0
16280 Bulk Product c54654dc Home & Garden $495.52 39 0.2 77 BULK-f88f542d
16281 Bulk Product b8119abd Clothing $58.47 41 4.8 75 BULK-4b0804ff
16282 Bulk Product 9046a01f Home & Garden $623.81 410 1.2 54 BULK-ec2b93df
16283 Bulk Product 96611a27 Electronics $559.49 405 1.0 30 BULK-e1f333ec
16284 Bulk Product f0a60a10 Sports & Outdoors $848.53 416 4.0 57 BULK-bd6a2ad5
16285 Bulk Product 3a7a9ff5 Books $498.92 103 1.0 64 BULK-f332d009
16286 Bulk Product 933fa05f Electronics $725.50 176 4.4 35 BULK-c4e56627
16287 Bulk Product ac0fe267 Clothing $91.64 397 1.0 57 BULK-2652c0fa
16288 Bulk Product fa606127 Clothing $416.95 366 4.5 2 BULK-0eb4385a
16289 Bulk Product 8cce3588 Home & Garden $692.19 138 3.9 26 BULK-9c7dc000
16290 Bulk Product c2ec37ab Clothing $42.46 296 0.4 78 BULK-34c62de5
16291 Bulk Product a3e72873 Sports & Outdoors $164.19 238 1.2 62 BULK-6170f140
16292 Bulk Product cdc2e545 Clothing $112.13 238 4.5 51 BULK-4da9c7ce
16293 Bulk Product 779a6b6f Sports & Outdoors $737.59 210 2.4 34 BULK-80300221
16294 Bulk Product 7e60908c Home & Garden $93.44 311 2.7 24 BULK-a4d8e3fe
16295 Bulk Product afa4035a Electronics $356.34 498 4.5 47 BULK-0377a180
16296 Bulk Product 776aef02 Clothing $428.53 467 0.1 81 BULK-3333d910
16297 Bulk Product 2d4c78e8 Home & Garden $300.00 380 5.0 25 BULK-283e0b79
16298 Bulk Product 5f0be19b Toys & Games $662.32 52 3.4 97 BULK-2005fac0
16299 Bulk Product 8bece07c Clothing $168.77 335 4.2 73 BULK-5c0b0cc1
16300 Bulk Product c3d67025 Home & Garden $598.79 36 1.8 46 BULK-35b524dc
16301 Bulk Product 81728c02 Sports & Outdoors $258.87 364 1.0 34 BULK-1e1baa5a
16302 Bulk Product 646a6fa1 Books $932.86 78 3.1 25 BULK-42968db9
16303 Bulk Product bf8bd82f Toys & Games $719.21 39 0.7 55 BULK-6d7f77ad
16304 Bulk Product a736b5ec Clothing $109.80 111 2.3 84 BULK-928a9dae
16305 Bulk Product 232dea33 Electronics $297.14 295 0.8 99 BULK-fb536d4b
16306 Bulk Product 702d541b Sports & Outdoors $413.88 115 1.4 96 BULK-48a9460e
16307 Bulk Product 81feb13f Sports & Outdoors $163.53 62 0.4 20 BULK-74b4e7d8
16308 Bulk Product 5f228587 Home & Garden $985.22 411 4.2 4 BULK-33075ba2
16309 Bulk Product 6453befb Books $621.24 491 0.7 44 BULK-d00cfda5
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