Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

41 ms

Page Size

50

Current Page

383 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 383 Results Showing 19101 - 19150 of 24441

ID Name Category Price Stock Rating Reviews SKU
19660 Bulk Product 7ffd5acf Clothing $100.22 308 2.7 47 BULK-fe0379f4
19661 Bulk Product 1e067945 Books $117.96 16 4.9 10 BULK-ff516d48
19662 Bulk Product 0b41f1b6 Clothing $703.37 86 4.1 21 BULK-7be16e25
19663 Bulk Product 25c0cfff Clothing $147.16 121 1.0 30 BULK-dd238ac2
19664 Bulk Product ba931484 Sports & Outdoors $757.85 24 1.1 4 BULK-740220cc
19665 Bulk Product e11d7b00 Sports & Outdoors $283.46 453 4.3 95 BULK-6c1cb091
19666 Bulk Product cfcbc6f0 Electronics $16.02 21 4.1 11 BULK-706de316
19667 Bulk Product 1fcc2c36 Toys & Games $229.40 198 0.0 60 BULK-122d36dd
19668 Bulk Product 554c2758 Electronics $796.07 485 1.2 44 BULK-fbc7d9e1
19669 Bulk Product bdee0a81 Books $738.60 128 3.3 2 BULK-7ea1955b
19670 Bulk Product 64c666d3 Books $602.23 103 1.7 36 BULK-02de3bb1
19671 Bulk Product ed60b842 Electronics $734.77 297 2.8 4 BULK-b6c2777c
19672 Bulk Product fb27f436 Electronics $447.30 276 2.1 82 BULK-ec197d52
19673 Bulk Product 5bbdcf13 Toys & Games $945.74 338 2.6 48 BULK-458c9628
19674 Bulk Product a680f17e Sports & Outdoors $940.49 20 1.3 32 BULK-4e8924ef
19675 Bulk Product dd11b652 Clothing $343.17 241 4.2 61 BULK-40ac071b
19676 Bulk Product a00196be Toys & Games $927.67 144 0.7 93 BULK-db49af8d
19677 Bulk Product 74746dc6 Toys & Games $877.45 142 2.7 2 BULK-3d2ea8df
19678 Bulk Product 1d32f75b Electronics $886.72 310 1.7 60 BULK-0a9eef63
19679 Bulk Product 25a0ecc0 Clothing $957.50 422 0.5 29 BULK-7b2d93fe
19680 Bulk Product 60ff3b4a Electronics $578.89 416 2.9 62 BULK-a981d195
19681 Bulk Product d557a001 Sports & Outdoors $924.61 399 1.3 71 BULK-6532dff3
19682 Bulk Product 8b46d64d Home & Garden $741.35 263 1.6 59 BULK-a814e291
19683 Bulk Product e063fe7c Books $97.85 395 3.3 99 BULK-bc929605
19684 Bulk Product d284210e Electronics $909.20 235 0.6 74 BULK-85a933ba
19685 Bulk Product f4496ee6 Toys & Games $953.59 270 1.9 42 BULK-fb42ee2e
19686 Bulk Product 85702b8e Books $717.17 367 1.1 0 BULK-ff999cc9
19687 Bulk Product 3743f5a4 Sports & Outdoors $725.74 335 1.7 81 BULK-894b051a
19688 Bulk Product ddc77b89 Books $980.35 241 4.7 91 BULK-e906971a
19689 Bulk Product ca99030e Toys & Games $272.41 257 2.6 21 BULK-7697947b
19690 Bulk Product c439da97 Books $991.83 87 0.7 27 BULK-3d9edfca
19691 Bulk Product 0e79bd14 Home & Garden $277.47 305 2.9 50 BULK-55f4feee
19692 Bulk Product d907245c Sports & Outdoors $701.37 414 3.6 45 BULK-f1b27ad0
19693 Bulk Product d4c7f191 Home & Garden $362.51 173 4.7 55 BULK-a78daf24
19694 Bulk Product 2011d204 Electronics $29.88 359 4.6 46 BULK-5994e170
19695 Bulk Product 1f04550a Books $851.25 17 2.4 93 BULK-fc8aded3
19696 Bulk Product a2a84d7c Toys & Games $553.73 238 4.7 14 BULK-28c00bd7
19697 Bulk Product acaffd3f Home & Garden $661.43 50 2.6 31 BULK-906b5137
19698 Bulk Product 4e0f9026 Books $709.55 456 1.0 88 BULK-6cd86fbb
19699 Bulk Product e987e591 Sports & Outdoors $24.28 92 4.4 34 BULK-5622c29e
19700 Bulk Product da8ecd58 Toys & Games $281.76 467 1.4 45 BULK-d3a19a71
19701 Bulk Product 1a63500a Toys & Games $599.96 252 2.4 73 BULK-818c557b
19702 Bulk Product 79a085d8 Electronics $765.60 328 3.2 81 BULK-cbbeb96f
19703 Bulk Product 229d0222 Sports & Outdoors $10.04 255 0.6 9 BULK-71267bdb
19704 Bulk Product 6bee4d8a Books $806.59 209 2.2 73 BULK-2addf1fa
19705 Bulk Product 6f0f8a88 Sports & Outdoors $827.46 186 2.4 65 BULK-e4d5d569
19706 Bulk Product 6804745c Home & Garden $944.32 313 0.0 8 BULK-cf328a2a
19707 Bulk Product 1ef1ba37 Sports & Outdoors $28.35 63 0.5 25 BULK-2bcbec57
19708 Bulk Product f8575a08 Electronics $100.96 305 1.3 90 BULK-c2a2cd98
19709 Bulk Product de9bd555 Electronics $807.77 335 0.4 83 BULK-6b6ece0b
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