Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

47 ms

Page Size

50

Current Page

137 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 137 Results Showing 6801 - 6850 of 24441

ID Name Category Price Stock Rating Reviews SKU
7360 Bulk Product f5c26a60 Home & Garden $212.79 198 2.9 36 BULK-f780b2e5
7361 Bulk Product bc441f36 Electronics $285.42 430 1.8 6 BULK-780016dc
7362 Bulk Product 22d81b53 Toys & Games $609.43 108 0.7 79 BULK-977a496d
7363 Bulk Product 1945e582 Books $879.09 115 2.3 4 BULK-9be08883
7364 Bulk Product ee6dd437 Electronics $888.74 465 4.5 46 BULK-369e3d49
7365 Bulk Product e6c2a01e Clothing $18.27 161 1.0 39 BULK-5df8ff2e
7366 Bulk Product d06cdda7 Books $234.80 101 3.3 64 BULK-e2f84869
7367 Bulk Product 60d95879 Home & Garden $686.36 494 1.5 91 BULK-e4693639
7368 Bulk Product c440fd43 Books $828.65 220 3.4 10 BULK-cb86a058
7369 Bulk Product c0fdd3aa Toys & Games $463.60 399 3.5 52 BULK-7fd1e6ef
7370 Bulk Product e5751e63 Sports & Outdoors $153.15 368 0.1 0 BULK-26aae8ee
7371 Bulk Product 9d623179 Toys & Games $531.28 380 0.5 38 BULK-ca6bd8cb
7372 Bulk Product ff90d42e Books $660.52 270 4.2 50 BULK-a3aa2fc6
7373 Bulk Product 61930f5f Home & Garden $703.03 351 4.0 10 BULK-59cbcab2
7374 Bulk Product ddf7da40 Books $808.09 411 2.7 79 BULK-8352e580
7375 Bulk Product 26d5a0a7 Clothing $790.45 377 0.4 80 BULK-687ab785
7376 Bulk Product a0d75239 Clothing $243.05 69 0.2 72 BULK-f839e2e4
7377 Bulk Product 0e813b92 Clothing $962.72 229 2.7 71 BULK-ba3c47d3
7378 Bulk Product 1dc848db Books $1,008.01 63 4.6 54 BULK-c30d8678
7379 Bulk Product c1e1e47c Sports & Outdoors $784.84 268 0.4 81 BULK-75bb7abe
7380 Bulk Product deea7d71 Clothing $843.34 461 4.2 45 BULK-d3bda497
7381 Bulk Product d9fb7937 Electronics $10.71 376 2.9 65 BULK-624016df
7382 Bulk Product b0800e22 Clothing $489.87 361 3.8 78 BULK-c373e9fb
7383 Bulk Product 04390931 Books $818.05 354 4.3 68 BULK-7d5ed404
7384 Bulk Product c84eff8d Home & Garden $262.67 29 4.8 17 BULK-1fa45faf
7385 Bulk Product d789643e Sports & Outdoors $30.60 18 1.2 4 BULK-d36c4b65
7386 Bulk Product 63d00d41 Clothing $195.65 97 1.1 85 BULK-95d7cbae
7387 Bulk Product 4c8db492 Books $703.35 450 0.8 92 BULK-567e9f72
7388 Bulk Product f27e709a Clothing $852.85 335 0.1 6 BULK-0d0c37c8
7389 Bulk Product 8836d61d Books $496.42 466 2.2 41 BULK-b2dd9d19
7390 Bulk Product e21b62c4 Clothing $435.87 74 1.5 40 BULK-16c6af26
7391 Bulk Product 35b1c436 Electronics $265.95 287 2.5 58 BULK-1e30deb2
7392 Bulk Product 6dfd48fd Clothing $132.01 447 3.8 47 BULK-2fa5e119
7393 Bulk Product 0e28ec93 Books $13.16 349 3.2 43 BULK-92ad6fb6
7394 Bulk Product 3d356d17 Sports & Outdoors $759.99 350 4.6 23 BULK-8abeb2a2
7395 Bulk Product 7978f98f Toys & Games $47.31 193 4.4 70 BULK-ea7e76a4
7396 Bulk Product 0af94598 Sports & Outdoors $553.47 285 3.8 44 BULK-c41cc1d1
7397 Bulk Product 2d34ff2d Sports & Outdoors $399.66 387 2.1 47 BULK-fa0b4297
7398 Bulk Product 7ff5ff2f Clothing $116.84 205 4.2 48 BULK-15c19575
7399 Bulk Product 5de0bccf Books $947.81 429 3.5 67 BULK-81a4d1c6
7400 Bulk Product 794dd3dd Electronics $665.06 186 0.0 87 BULK-5932bb8e
7401 Bulk Product b7b4e98d Sports & Outdoors $366.39 475 0.8 49 BULK-28844236
7402 Bulk Product 09e07366 Books $448.18 129 0.2 64 BULK-60e25420
7403 Bulk Product 58d8e0f9 Toys & Games $38.42 69 0.7 28 BULK-39c8dd71
7404 Bulk Product 7ea029d4 Home & Garden $900.28 126 2.5 97 BULK-13f7701f
7405 Bulk Product 2bf1cdfe Toys & Games $515.83 248 4.7 46 BULK-c5695d16
7406 Bulk Product 4b663ce6 Clothing $782.55 116 3.6 12 BULK-92d4657f
7407 Bulk Product 61d73bd6 Electronics $939.31 416 1.4 84 BULK-60d4fb85
7408 Bulk Product c5e85de0 Clothing $97.15 396 5.0 46 BULK-ec73e035
7409 Bulk Product d1f494ba Electronics $734.41 231 1.2 14 BULK-621a95ef
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