Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

17 ms

Page Size

50

Current Page

176 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 176 Results Showing 8751 - 8800 of 24441

ID Name Category Price Stock Rating Reviews SKU
9310 Bulk Product 1e39b3a7 Sports & Outdoors $746.18 49 4.2 62 BULK-eed86f53
9311 Bulk Product dbf2f821 Electronics $329.77 199 2.6 53 BULK-54065a6f
9312 Bulk Product 86d473d7 Sports & Outdoors $997.79 181 4.5 76 BULK-3d6cb7c8
9313 Bulk Product f93e7aa9 Home & Garden $420.20 326 4.2 72 BULK-de5a4cb3
9314 Bulk Product e0037276 Home & Garden $16.90 348 0.4 2 BULK-4ba3ec8f
9315 Bulk Product dc2a3280 Toys & Games $193.79 248 2.6 28 BULK-3e1b6174
9316 Bulk Product 6aefeb56 Home & Garden $568.43 478 1.9 78 BULK-bf47c6be
9317 Bulk Product afef4970 Toys & Games $882.67 346 4.5 60 BULK-671c1686
9318 Bulk Product e71eab00 Toys & Games $460.33 60 0.1 24 BULK-d5c3344d
9319 Bulk Product cc73f463 Home & Garden $81.68 323 0.9 93 BULK-076911f4
9320 Bulk Product 5464b185 Home & Garden $908.58 488 0.1 18 BULK-cdbc6f09
9321 Bulk Product a984d986 Books $210.24 435 0.8 79 BULK-7b149cf9
9322 Bulk Product 75b96cea Sports & Outdoors $509.99 410 2.1 31 BULK-29abcd7a
9323 Bulk Product 2103cff5 Home & Garden $252.60 66 4.1 17 BULK-482a34b6
9324 Bulk Product 083cd2a8 Sports & Outdoors $1,001.68 278 4.3 67 BULK-fcad2c13
9325 Bulk Product 98f79f36 Electronics $255.73 248 4.0 83 BULK-b342b3ff
9326 Bulk Product 50efa696 Books $829.99 344 4.5 2 BULK-6a5f39ef
9327 Bulk Product 7f6db982 Sports & Outdoors $885.30 223 0.2 15 BULK-b10b2d84
9328 Bulk Product b7cab851 Clothing $881.60 83 2.4 82 BULK-4bc74a26
9329 Bulk Product 72299f79 Electronics $437.90 170 1.5 5 BULK-41a74d6a
9330 Bulk Product f1588782 Home & Garden $40.44 329 2.2 66 BULK-20ff2fc6
9331 Bulk Product eb5b9d77 Sports & Outdoors $104.28 250 3.0 18 BULK-2e661802
9332 Bulk Product 21848b70 Toys & Games $120.33 395 2.6 39 BULK-76e38929
9333 Bulk Product 2e7d145f Electronics $142.15 347 2.2 10 BULK-78687737
9334 Bulk Product 7898d9f4 Home & Garden $443.69 240 3.8 15 BULK-cb4e7b8c
9335 Bulk Product 7e0efb57 Toys & Games $662.93 215 0.9 39 BULK-25646d4c
9336 Bulk Product 2b672755 Clothing $485.03 343 4.6 18 BULK-dbd49ec0
9337 Bulk Product a7129f35 Books $452.65 95 4.5 50 BULK-12873556
9338 Bulk Product 2645b657 Books $560.49 350 3.7 27 BULK-06f88605
9339 Bulk Product 1a852faa Clothing $599.36 359 0.4 96 BULK-91666d3c
9340 Bulk Product 8eeb96c8 Clothing $68.52 325 2.8 57 BULK-cebacb85
9341 Bulk Product ac68dc37 Electronics $617.50 465 1.7 7 BULK-b60eade2
9342 Bulk Product c282a4bb Toys & Games $748.14 22 1.3 12 BULK-fa7a3164
9343 Bulk Product 167cfcef Clothing $852.60 146 2.6 74 BULK-9680d011
9344 Bulk Product 735c7199 Clothing $904.94 65 1.2 19 BULK-a092d9ab
9345 Bulk Product 152c7030 Clothing $695.09 461 0.3 36 BULK-edcea634
9346 Bulk Product 9ec9b8fd Sports & Outdoors $837.04 222 2.7 82 BULK-3bb67723
9347 Bulk Product dc93ade5 Clothing $742.54 82 0.3 14 BULK-423c76dc
9348 Bulk Product 7a0ba3c2 Toys & Games $287.56 375 0.3 61 BULK-111e5dea
9349 Bulk Product 54463bf0 Clothing $916.03 268 1.1 56 BULK-40d8136d
9350 Bulk Product b261436a Sports & Outdoors $885.50 269 3.2 94 BULK-e3f9d481
9351 Bulk Product 90cbd7d7 Books $165.06 360 4.6 15 BULK-985c0bda
9352 Bulk Product 92b455c5 Sports & Outdoors $364.95 42 0.7 30 BULK-3fca1110
9353 Bulk Product 37e7bef4 Electronics $256.46 45 4.6 16 BULK-3a6a33b7
9354 Bulk Product 6ad42d0b Electronics $931.08 349 1.9 15 BULK-19b48401
9355 Bulk Product 78f0ad9c Toys & Games $10.12 15 3.8 67 BULK-780abea4
9356 Bulk Product e57360bc Sports & Outdoors $715.85 453 0.1 83 BULK-e792443a
9357 Bulk Product cdb89af4 Toys & Games $394.47 89 4.7 4 BULK-581dbe98
9358 Bulk Product 3e39c77b Home & Garden $822.74 214 2.3 74 BULK-de0a3c92
9359 Bulk Product 3b6d9f7a Clothing $504.62 123 0.8 87 BULK-312dd679
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