Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

14 ms

Page Size

50

Current Page

335 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 335 Results Showing 16701 - 16750 of 24441

ID Name Category Price Stock Rating Reviews SKU
17260 Bulk Product a154c81b Toys & Games $304.60 55 1.8 90 BULK-c4406ee1
17261 Bulk Product 7d552f42 Electronics $474.41 124 1.6 22 BULK-a26a57c2
17262 Bulk Product 174e0095 Books $17.96 168 1.9 46 BULK-a5b7e0d4
17263 Bulk Product 004121d9 Toys & Games $863.41 285 2.1 72 BULK-00569627
17264 Bulk Product 5ffdbac3 Home & Garden $229.60 467 2.3 55 BULK-90500e0a
17265 Bulk Product fdf8f5d7 Sports & Outdoors $607.91 68 4.6 8 BULK-0f82a208
17266 Bulk Product 6e48c6c3 Books $808.80 216 4.1 32 BULK-ef76b771
17267 Bulk Product 84d4e498 Books $188.57 26 2.0 86 BULK-22fbb0d7
17268 Bulk Product b7998844 Clothing $26.84 220 0.3 36 BULK-47768165
17269 Bulk Product 51fa0f61 Books $581.95 380 4.6 71 BULK-d3487ef6
17270 Bulk Product 7d5de5a6 Home & Garden $246.69 158 0.1 82 BULK-e3084291
17271 Bulk Product 6525056e Sports & Outdoors $925.97 248 0.4 30 BULK-9ef67db0
17272 Bulk Product 0f2f7101 Toys & Games $310.38 165 2.1 4 BULK-fbcaeeac
17273 Bulk Product e0a70785 Clothing $984.44 346 3.3 99 BULK-bf3263d6
17274 Bulk Product f2f51feb Home & Garden $725.16 4 4.2 60 BULK-248beb5b
17275 Bulk Product ce086aa8 Toys & Games $911.63 443 0.1 29 BULK-4eae1752
17276 Bulk Product f5c15944 Toys & Games $354.19 155 2.4 80 BULK-9d6f48be
17277 Bulk Product 376003ec Clothing $332.70 403 3.4 67 BULK-c648a4bd
17278 Bulk Product 43c5a6f1 Clothing $266.46 401 3.3 75 BULK-071bd791
17279 Bulk Product 700d4d20 Sports & Outdoors $219.17 498 3.8 33 BULK-afb69c41
17280 Bulk Product be7f9e68 Electronics $225.96 489 2.2 56 BULK-e2d2fcfd
17281 Bulk Product ac78fc1a Toys & Games $275.40 389 4.6 76 BULK-856c17b8
17282 Bulk Product 6003ef74 Toys & Games $937.12 416 3.9 45 BULK-401315d0
17283 Bulk Product a10f7149 Sports & Outdoors $550.33 212 1.0 48 BULK-f72b524c
17284 Bulk Product 052f9df8 Sports & Outdoors $349.72 361 4.1 62 BULK-f2239117
17285 Bulk Product 320c9374 Sports & Outdoors $377.88 60 1.5 85 BULK-383a27c2
17286 Bulk Product 18841faa Books $756.02 480 2.1 11 BULK-ebe7afaf
17287 Bulk Product 5744f562 Sports & Outdoors $860.22 379 0.3 61 BULK-085ae601
17288 Bulk Product d7b541ea Home & Garden $553.45 150 0.2 54 BULK-b129cd68
17289 Bulk Product 4d4a4925 Home & Garden $396.15 227 1.3 51 BULK-869c3424
17290 Bulk Product d0ac5c5b Clothing $852.65 496 2.0 84 BULK-1e2f7fd2
17291 Bulk Product 75c45fde Books $655.96 178 1.5 44 BULK-484e035f
17292 Bulk Product 7787fad4 Electronics $363.63 267 0.4 41 BULK-b450d61b
17293 Bulk Product f8f6c1df Sports & Outdoors $344.41 238 0.5 92 BULK-b6246f6a
17294 Bulk Product cc2e7ce2 Electronics $280.41 138 3.1 81 BULK-2f72d2e2
17295 Bulk Product 06ea4f87 Books $994.37 176 1.2 50 BULK-a0f03816
17296 Bulk Product ce0ae408 Home & Garden $837.05 57 1.0 83 BULK-345d09d9
17297 Bulk Product 5931976e Books $592.72 141 2.2 83 BULK-d3b5dad1
17298 Bulk Product 52857baf Clothing $296.40 216 3.4 22 BULK-bb3b2771
17299 Bulk Product e19e4ccb Toys & Games $966.63 177 4.2 41 BULK-eda12ef2
17300 Bulk Product a5d99113 Clothing $58.10 405 0.3 46 BULK-eebefc4f
17301 Bulk Product d6002cbb Books $777.59 405 3.2 39 BULK-2b45e2aa
17302 Bulk Product 65f29d86 Sports & Outdoors $522.05 138 4.3 11 BULK-ef9966da
17303 Bulk Product 93b1d575 Books $659.51 160 3.3 78 BULK-8b1071cc
17304 Bulk Product ee00f5e7 Electronics $551.95 391 4.2 33 BULK-ec9aae16
17305 Bulk Product bc2491b7 Sports & Outdoors $648.99 347 3.0 40 BULK-6c9f0b5e
17306 Bulk Product 1bbf7208 Toys & Games $405.00 484 4.1 0 BULK-edeca44e
17307 Bulk Product 61cfda83 Electronics $788.89 124 0.6 26 BULK-03be09b2
17308 Bulk Product 9e68b947 Books $890.39 238 0.4 37 BULK-c9932a55
17309 Bulk Product c826c79c Clothing $851.22 493 1.2 24 BULK-e961d1f1
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