Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

45 ms

Page Size

50

Current Page

216 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 216 Results Showing 10751 - 10800 of 24441

ID Name Category Price Stock Rating Reviews SKU
11310 Bulk Product 832967c4 Home & Garden $781.34 245 3.5 89 BULK-83f5ed51
11311 Bulk Product a18d6735 Toys & Games $313.82 88 2.2 10 BULK-e5c59de0
11312 Bulk Product 5f2cd752 Books $423.36 234 2.3 12 BULK-db3fa52f
11313 Bulk Product f24a1385 Toys & Games $918.60 287 1.5 8 BULK-e01e5a41
11314 Bulk Product 2cc67022 Toys & Games $692.11 78 4.8 24 BULK-0700091a
11315 Bulk Product d405d1c4 Sports & Outdoors $475.80 323 4.0 16 BULK-2af8b1f3
11316 Bulk Product bb3c6805 Clothing $341.44 53 0.1 2 BULK-7f7a6d40
11317 Bulk Product 82375a34 Electronics $289.55 318 1.6 0 BULK-7c70bd25
11318 Bulk Product 6503d061 Electronics $831.24 419 2.1 38 BULK-2e15a802
11319 Bulk Product 4ac16aac Toys & Games $252.70 354 4.7 88 BULK-ee50a3c8
11320 Bulk Product 802798a7 Toys & Games $50.47 190 1.6 90 BULK-c6083ef1
11321 Bulk Product 30ef063d Home & Garden $211.69 393 3.5 10 BULK-c7121630
11322 Bulk Product fd427c55 Clothing $588.62 331 4.9 36 BULK-7ac09b3a
11323 Bulk Product c6b3a92b Books $557.44 112 2.3 26 BULK-936c8709
11324 Bulk Product 7c7169ad Clothing $704.44 316 0.3 67 BULK-0923cc86
11325 Bulk Product 5643b501 Electronics $428.89 285 0.1 64 BULK-52cb71c5
11326 Bulk Product fcdb4c8b Electronics $949.25 147 0.2 10 BULK-647399d2
11327 Bulk Product 5ce49caf Clothing $726.98 439 0.2 95 BULK-5c88f96d
11328 Bulk Product a3879473 Electronics $355.72 476 0.5 65 BULK-07af0a70
11329 Bulk Product 8df816ae Home & Garden $169.48 284 3.3 34 BULK-e753e1d7
11330 Bulk Product 6ebbc03a Toys & Games $681.33 94 5.0 42 BULK-5ff6656a
11331 Bulk Product ca59c3f1 Clothing $43.30 271 0.6 27 BULK-c8daaef6
11332 Bulk Product 14508a6c Toys & Games $791.13 375 4.3 62 BULK-31429ddd
11333 Bulk Product 01ce5b11 Clothing $875.03 223 1.3 40 BULK-f80e1223
11334 Bulk Product 0150713e Books $867.80 118 2.0 80 BULK-47d736e9
11335 Bulk Product a3608393 Toys & Games $26.09 389 0.4 57 BULK-37a34287
11336 Bulk Product 51e803a1 Home & Garden $273.07 400 0.3 36 BULK-85dbfcb8
11337 Bulk Product 7f039952 Sports & Outdoors $333.74 79 3.6 36 BULK-2dbb9c5c
11338 Bulk Product 4ab0b182 Sports & Outdoors $374.29 14 1.1 50 BULK-1454cd28
11339 Bulk Product 9e2356cd Home & Garden $198.63 387 1.2 67 BULK-c42cfd16
11340 Bulk Product f71400b6 Books $831.03 403 1.4 96 BULK-1c1bb040
11341 Bulk Product 00ae3a89 Electronics $557.38 377 2.1 99 BULK-c063525c
11342 Bulk Product af46f991 Home & Garden $535.90 121 2.0 25 BULK-d7efe390
11343 Bulk Product 125f56f2 Sports & Outdoors $74.75 439 2.8 18 BULK-51c15d26
11344 Bulk Product 3bcc09d3 Sports & Outdoors $952.65 407 0.3 30 BULK-4d406802
11345 Bulk Product 8efdd125 Electronics $842.19 344 0.5 48 BULK-c208d299
11346 Bulk Product 4b2bbf53 Books $175.14 197 4.4 15 BULK-2d78c993
11347 Bulk Product 16ac082d Sports & Outdoors $474.64 81 1.8 53 BULK-83270fd5
11348 Bulk Product b52ea448 Toys & Games $415.39 220 3.7 74 BULK-73d8aacf
11349 Bulk Product 328608da Toys & Games $389.13 334 1.0 1 BULK-33a6c38d
11350 Bulk Product c902d36e Home & Garden $97.04 334 1.3 85 BULK-d59542b3
11351 Bulk Product 8b97f761 Sports & Outdoors $850.61 170 3.3 52 BULK-834cf0ee
11352 Bulk Product 232069cb Clothing $255.81 468 1.3 95 BULK-d2239152
11353 Bulk Product 3f37b070 Sports & Outdoors $75.65 275 3.4 46 BULK-042717b0
11354 Bulk Product beeb6cf8 Electronics $405.71 324 0.1 84 BULK-0c994e72
11355 Bulk Product 380d45c8 Sports & Outdoors $123.23 224 2.1 38 BULK-f3c5d413
11356 Bulk Product 50248473 Clothing $275.35 186 1.0 4 BULK-bf10fd4c
11357 Bulk Product ac078da4 Electronics $776.55 325 4.1 1 BULK-996c0cdc
11358 Bulk Product e93f5448 Books $921.22 393 4.1 90 BULK-022b28c1
11359 Bulk Product 57e0ddd6 Sports & Outdoors $10.36 431 0.2 71 BULK-7bc4ac8a
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