Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

59 ms

Page Size

50

Current Page

298 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 298 Results Showing 14851 - 14900 of 24441

ID Name Category Price Stock Rating Reviews SKU
15410 Bulk Product 6f370438 Clothing $272.61 101 3.1 72 BULK-af01042e
15411 Bulk Product 51cecde9 Electronics $406.37 260 0.3 88 BULK-37bd5c2b
15412 Bulk Product f450fd76 Home & Garden $217.93 341 2.1 62 BULK-19c0f1ca
15413 Bulk Product fdc1471a Sports & Outdoors $768.42 345 4.1 17 BULK-d22a54e3
15414 Bulk Product df142dec Home & Garden $663.35 298 1.8 8 BULK-23e921be
15415 Bulk Product 2e49bb77 Books $397.99 289 0.3 27 BULK-66647cbf
15416 Bulk Product 7e8e0571 Electronics $338.49 370 3.3 61 BULK-e91b42f7
15417 Bulk Product 66e2c219 Home & Garden $54.80 6 0.4 27 BULK-c7d45d24
15418 Bulk Product f2495cdd Clothing $794.02 110 3.8 70 BULK-10ce0dc1
15419 Bulk Product dea20240 Electronics $149.45 453 0.9 4 BULK-72d364a2
15420 Bulk Product 59302905 Electronics $514.75 374 3.1 57 BULK-918fe897
15421 Bulk Product d5be4ac5 Toys & Games $438.87 314 0.6 89 BULK-defb860f
15422 Bulk Product f3949478 Clothing $196.32 107 0.0 52 BULK-2dea7fd3
15423 Bulk Product 7ab8a28b Clothing $218.16 228 2.8 98 BULK-8bc89157
15424 Bulk Product 721ad48a Toys & Games $495.55 426 2.3 44 BULK-eb6376fe
15425 Bulk Product 74727fe0 Electronics $181.56 263 4.5 99 BULK-318cdf9f
15426 Bulk Product 9a67e761 Electronics $924.17 429 1.6 62 BULK-862a2138
15427 Bulk Product 7f77cb0d Electronics $323.92 25 4.9 12 BULK-d143c8fc
15428 Bulk Product 0b5083cb Home & Garden $276.40 392 0.8 99 BULK-27f56552
15429 Bulk Product 2756f343 Toys & Games $842.94 108 0.3 33 BULK-205a83cb
15430 Bulk Product a48a00b7 Clothing $422.52 200 2.2 66 BULK-db872011
15431 Bulk Product a236ee50 Books $792.17 268 4.9 19 BULK-23fc0078
15432 Bulk Product 94c9669e Toys & Games $86.93 489 4.6 93 BULK-81d56047
15433 Bulk Product f2fe5d5a Electronics $825.39 152 0.2 56 BULK-4cffbd6c
15434 Bulk Product 3e4d1977 Sports & Outdoors $659.22 327 2.7 82 BULK-e5c3d7db
15435 Bulk Product cef07dcc Toys & Games $467.26 448 2.1 44 BULK-d3ce4db9
15436 Bulk Product 88454354 Home & Garden $845.58 169 3.9 87 BULK-127ec682
15437 Bulk Product 6abdb534 Electronics $492.60 374 4.2 19 BULK-7f75c132
15438 Bulk Product f9e34879 Home & Garden $974.95 319 3.2 28 BULK-a333bef2
15439 Bulk Product a2ce84d7 Home & Garden $651.47 479 0.4 98 BULK-4625e984
15440 Bulk Product 58666300 Toys & Games $686.99 195 3.6 62 BULK-c7b3d19c
15441 Bulk Product 69c9ed05 Electronics $776.40 78 3.2 28 BULK-f2b7fdcd
15442 Bulk Product 47f6dac1 Books $840.65 448 2.8 13 BULK-7a888710
15443 Bulk Product ee833524 Home & Garden $212.24 13 4.8 72 BULK-6834dcad
15444 Bulk Product bf40d89f Clothing $570.99 57 0.8 89 BULK-e26ecd61
15445 Bulk Product 64b010ab Electronics $31.97 344 0.8 33 BULK-2eba2f90
15446 Bulk Product 2587cd16 Sports & Outdoors $283.37 415 0.3 3 BULK-8e39b349
15447 Bulk Product 93297537 Toys & Games $773.03 242 4.3 62 BULK-9688407c
15448 Bulk Product e22bf46e Books $255.99 256 2.8 31 BULK-7a8a2c71
15449 Bulk Product 42aa190b Sports & Outdoors $333.96 8 3.2 42 BULK-1c87c18b
15450 Bulk Product 0cf46e2d Home & Garden $480.20 276 1.9 3 BULK-6d6d80c7
15451 Bulk Product 16ccd30c Home & Garden $830.59 72 0.0 62 BULK-0dd7c424
15452 Bulk Product f1afc89a Electronics $304.76 261 1.1 60 BULK-b209ae7c
15453 Bulk Product 122d0b27 Sports & Outdoors $834.92 405 2.2 69 BULK-2615f697
15454 Bulk Product 20fdc1e3 Electronics $534.87 323 1.0 34 BULK-f679de75
15455 Bulk Product 61083b7a Toys & Games $490.33 158 1.9 79 BULK-9af9e67d
15456 Bulk Product 5e799e37 Home & Garden $100.46 35 0.2 54 BULK-736d3259
15457 Bulk Product 9ba38eab Books $567.71 123 4.3 58 BULK-f4100b80
15458 Bulk Product ed24197d Home & Garden $409.21 352 4.9 0 BULK-6b391e3e
15459 Bulk Product 1c594e28 Books $882.72 410 0.4 62 BULK-dd73a1b4
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