Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

54 ms

Page Size

50

Current Page

485 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 485 Results Showing 24201 - 24250 of 24441

ID Name Category Price Stock Rating Reviews SKU
24760 Bulk Product ea62d6ec Books $498.37 495 1.7 24 BULK-becf3b88
24761 Bulk Product a8f87cc0 Books $93.98 367 1.5 36 BULK-c353d0b5
24762 Bulk Product 07671877 Electronics $268.24 154 0.7 31 BULK-1f21d159
24763 Bulk Product e55a4758 Sports & Outdoors $970.04 74 4.7 70 BULK-31f140bd
24764 Bulk Product b403da8b Electronics $272.33 237 1.4 37 BULK-453651bf
24765 Bulk Product 635bf88e Electronics $997.73 359 3.0 96 BULK-e347fb26
24766 Bulk Product 754d298e Books $268.31 3 3.7 47 BULK-e75aee99
24767 Bulk Product e8d8d37c Electronics $580.00 78 1.4 63 BULK-b9eef3f6
24768 Bulk Product fd6423a0 Toys & Games $692.21 111 3.9 9 BULK-cd936185
24769 Bulk Product a9072441 Clothing $984.66 8 2.1 42 BULK-5d845589
24770 Bulk Product 06b813cb Sports & Outdoors $331.30 245 2.9 40 BULK-defb3e7b
24771 Bulk Product 838a5f0e Toys & Games $189.96 361 1.0 29 BULK-3175dc18
24772 Bulk Product 7c1c43c2 Books $900.69 103 0.8 21 BULK-8fc4a668
24773 Bulk Product eb1a47dc Clothing $118.36 322 4.9 70 BULK-b72c4106
24774 Bulk Product 01785ba1 Home & Garden $66.17 264 2.6 59 BULK-faffecbf
24775 Bulk Product 95d4efaf Books $482.96 419 1.1 34 BULK-3640fb7d
24776 Bulk Product 77338da8 Books $112.48 6 2.8 3 BULK-869343aa
24777 Bulk Product aaf04053 Toys & Games $931.17 335 4.3 2 BULK-4257ec73
24778 Bulk Product 59ba9576 Home & Garden $536.46 37 1.1 6 BULK-71d327e6
24779 Bulk Product 05d392e8 Electronics $186.16 155 4.6 54 BULK-b5165f22
24780 Bulk Product a7247e67 Electronics $225.32 475 5.0 54 BULK-45a840ee
24781 Bulk Product e5c7fde4 Sports & Outdoors $704.95 91 4.0 41 BULK-138cd65c
24782 Bulk Product a17b061f Electronics $796.97 175 4.5 97 BULK-e3f7393a
24783 Bulk Product c6ad9983 Home & Garden $876.11 440 0.6 80 BULK-c77befaf
24784 Bulk Product c62857dd Electronics $876.55 140 4.2 63 BULK-bf85a836
24785 Bulk Product ef3b9bb7 Sports & Outdoors $786.83 108 2.4 47 BULK-6537b52d
24786 Bulk Product 1dd8b3e0 Electronics $693.46 70 4.1 50 BULK-a581112c
24787 Bulk Product 154efc6d Toys & Games $948.84 86 2.3 29 BULK-f2763b73
24788 Bulk Product 82bb9cf8 Home & Garden $346.50 17 4.3 61 BULK-8589df53
24789 Bulk Product 8a7b441e Books $822.97 45 4.8 15 BULK-8762ea34
24790 Bulk Product 3c2effce Books $745.45 244 3.6 66 BULK-a3e2d13b
24791 Bulk Product 3b829fdb Clothing $297.62 174 1.3 41 BULK-3887e3af
24792 Bulk Product df4bfe99 Electronics $449.53 95 3.5 76 BULK-27fee8e2
24793 Bulk Product 6e9fa0a2 Electronics $698.47 272 3.7 72 BULK-409cae7d
24794 Bulk Product 23e1801e Books $286.20 58 2.8 34 BULK-fdf8c566
24795 Bulk Product 972f9fe3 Clothing $735.95 30 3.1 60 BULK-e90c15db
24796 Bulk Product 63e1ca51 Sports & Outdoors $462.65 326 3.1 46 BULK-157b1e89
24797 Bulk Product 01645a93 Toys & Games $251.67 409 1.3 87 BULK-64a004d4
24798 Bulk Product 6d4ab6bd Clothing $950.23 430 4.9 36 BULK-2046f2fc
24799 Bulk Product fa7f498d Sports & Outdoors $796.62 438 0.0 66 BULK-95ed92f5
24800 Bulk Product 651186e5 Books $785.09 133 0.6 45 BULK-0d737403
24801 Bulk Product d701fda7 Home & Garden $979.19 119 4.5 93 BULK-b48e899e
24802 Bulk Product d0f287c3 Electronics $356.00 34 3.9 64 BULK-ce546d13
24803 Bulk Product 55c05845 Sports & Outdoors $631.37 394 4.8 81 BULK-3113e6b9
24804 Bulk Product 0af0e8cd Toys & Games $1,007.91 252 3.6 65 BULK-77868b97
24805 Bulk Product 06944d8b Home & Garden $929.37 107 4.7 40 BULK-ca8e01aa
24806 Bulk Product 531b6e26 Clothing $752.18 113 1.9 72 BULK-19dd7594
24807 Bulk Product 8cc2b44f Sports & Outdoors $698.55 409 1.0 51 BULK-a34d1121
24808 Bulk Product 16c2ec5b Clothing $537.99 63 1.7 75 BULK-a860f2bb
24809 Bulk Product 80259eeb Clothing $481.36 148 0.0 15 BULK-cc1b16dc
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