Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

14 ms

Page Size

50

Current Page

283 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 283 Results Showing 14101 - 14150 of 24441

ID Name Category Price Stock Rating Reviews SKU
14660 Bulk Product 7f2b5af0 Books $355.21 202 4.0 87 BULK-be03611d
14661 Bulk Product 879f3243 Clothing $828.83 193 1.0 28 BULK-0c423ab1
14662 Bulk Product 9021267a Electronics $201.70 117 0.8 64 BULK-b565c352
14663 Bulk Product a8f1b322 Home & Garden $757.11 437 1.8 1 BULK-fea7a7f5
14664 Bulk Product bbb856b5 Clothing $574.89 121 0.8 9 BULK-d8d86a15
14665 Bulk Product b7259614 Electronics $678.18 419 2.3 6 BULK-e37e6806
14666 Bulk Product 04f0448c Home & Garden $292.08 90 2.0 47 BULK-46fcb6bf
14667 Bulk Product c40c8965 Books $355.91 419 0.7 70 BULK-7a0a5c44
14668 Bulk Product 0a82040f Clothing $471.96 388 3.6 45 BULK-e058c89d
14669 Bulk Product 60c9e7e9 Electronics $147.27 25 2.6 30 BULK-07e357b9
14670 Bulk Product ffe5f5af Toys & Games $904.88 21 3.7 39 BULK-a46c5aa8
14671 Bulk Product 311ff81c Books $754.05 429 0.4 3 BULK-03e06ff6
14672 Bulk Product da183bbb Electronics $844.85 374 1.9 19 BULK-71cb70a5
14673 Bulk Product fd0de20a Home & Garden $585.45 313 4.0 10 BULK-32a1bcaa
14674 Bulk Product 4e20a516 Clothing $913.78 63 1.4 57 BULK-130459e2
14675 Bulk Product a1943475 Electronics $45.00 37 3.0 92 BULK-bc338c5d
14676 Bulk Product 87fde99d Clothing $906.44 391 5.0 95 BULK-77fb047c
14677 Bulk Product be38dcd8 Home & Garden $706.70 444 2.6 29 BULK-a8c02a7d
14678 Bulk Product cf14da67 Sports & Outdoors $44.04 4 4.2 94 BULK-094a5a81
14679 Bulk Product 0244242d Sports & Outdoors $740.81 150 4.7 97 BULK-d34371ef
14680 Bulk Product ed8c4d8c Toys & Games $357.64 269 2.4 77 BULK-598c973c
14681 Bulk Product 18d60195 Sports & Outdoors $115.89 413 0.1 10 BULK-5de6ef27
14682 Bulk Product bd95c796 Books $985.71 149 0.7 6 BULK-f17f6b51
14683 Bulk Product 4402aaf8 Books $323.01 401 2.3 63 BULK-31a9993f
14684 Bulk Product 9fed4032 Clothing $621.30 231 4.4 43 BULK-9bcc4c84
14685 Bulk Product 36f8658a Electronics $327.19 394 1.7 48 BULK-0283a716
14686 Bulk Product 2828ffce Electronics $524.28 37 0.4 3 BULK-2c75f0c6
14687 Bulk Product e2b790c0 Sports & Outdoors $490.06 334 3.4 70 BULK-5adf2f9a
14688 Bulk Product 6013f2c1 Toys & Games $822.60 138 4.2 11 BULK-be956c8d
14689 Bulk Product e066e78b Toys & Games $736.05 42 1.2 9 BULK-3e534c7e
14690 Bulk Product 0157ad19 Clothing $624.21 189 0.6 66 BULK-85f9f0dc
14691 Bulk Product e5680b33 Home & Garden $1,007.62 410 3.5 64 BULK-bd53c458
14692 Bulk Product d376504b Clothing $885.85 357 3.6 70 BULK-90230d2e
14693 Bulk Product 304e682e Toys & Games $609.67 483 3.6 4 BULK-9d2fe928
14694 Bulk Product 1feaa5ab Sports & Outdoors $26.52 437 4.8 21 BULK-dd503dc9
14695 Bulk Product e37602eb Toys & Games $455.79 88 4.3 78 BULK-8b39a148
14696 Bulk Product 63b8f6c1 Books $975.33 178 1.2 84 BULK-10ea48f5
14697 Bulk Product a25c93bf Books $35.90 117 3.7 78 BULK-c06d97b4
14698 Bulk Product 4054d03a Toys & Games $878.42 430 4.2 30 BULK-21e9bf81
14699 Bulk Product 1c62197b Sports & Outdoors $307.92 90 4.3 7 BULK-9dcfcdd6
14700 Bulk Product d6c802b3 Electronics $427.16 493 0.6 42 BULK-bb8d825d
14701 Bulk Product 27c567f5 Clothing $59.61 381 3.2 46 BULK-f4027973
14702 Bulk Product 980d2e5a Toys & Games $84.81 233 0.5 20 BULK-3b11c27e
14703 Bulk Product 902582d3 Sports & Outdoors $162.26 117 1.5 23 BULK-bd4f17fe
14704 Bulk Product 594020dd Home & Garden $161.45 290 0.7 24 BULK-7ebcd845
14705 Bulk Product 40c73bb6 Home & Garden $34.73 263 0.7 87 BULK-158766c6
14706 Bulk Product 229741bc Toys & Games $326.61 169 1.5 51 BULK-03c42e96
14707 Bulk Product 913d9d12 Home & Garden $679.34 128 2.3 13 BULK-d631c741
14708 Bulk Product 8a5b8dd8 Sports & Outdoors $577.13 271 4.5 59 BULK-ac92317e
14709 Bulk Product 5b2480b4 Electronics $846.17 152 1.1 34 BULK-cb5dd6b5
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