Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

52 ms

Page Size

50

Current Page

205 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 205 Results Showing 10201 - 10250 of 24441

ID Name Category Price Stock Rating Reviews SKU
10760 Bulk Product 90f4736d Books $554.15 464 0.9 43 BULK-f9c906d9
10761 Bulk Product aa64984e Sports & Outdoors $230.40 399 4.6 85 BULK-2ba79d95
10762 Bulk Product b13f0276 Clothing $363.60 307 1.4 8 BULK-93120f49
10763 Bulk Product 59ddde26 Toys & Games $174.04 181 4.9 37 BULK-708f47d0
10764 Bulk Product 679a3a42 Books $16.95 65 1.6 23 BULK-964d045d
10765 Bulk Product 7a933dda Toys & Games $957.88 179 2.1 22 BULK-ac664f39
10766 Bulk Product 9ec45527 Home & Garden $369.51 254 1.7 30 BULK-8b64e7d8
10767 Bulk Product 9ae05da6 Clothing $555.13 90 0.4 38 BULK-1f56da69
10768 Bulk Product 17eaf214 Toys & Games $998.21 151 0.1 78 BULK-b05f2c30
10769 Bulk Product 07546d85 Toys & Games $556.25 194 0.9 37 BULK-62b1e674
10770 Bulk Product ecf0f5a7 Home & Garden $44.18 280 3.0 28 BULK-8326db77
10771 Bulk Product 475971de Clothing $674.21 264 4.1 46 BULK-d9cb6614
10772 Bulk Product a2b8fa79 Sports & Outdoors $460.01 352 2.6 9 BULK-de1daf78
10773 Bulk Product 582d58cd Books $365.92 97 1.6 94 BULK-469448a6
10774 Bulk Product 269e2843 Books $470.48 2 4.1 88 BULK-7c2e1765
10775 Bulk Product 027b1adf Books $616.94 494 4.4 22 BULK-0ef3a949
10776 Bulk Product f2d55712 Electronics $307.21 499 1.2 14 BULK-bf3b71a9
10777 Bulk Product 059b50e6 Sports & Outdoors $137.88 424 4.3 65 BULK-104be443
10778 Bulk Product 672e349f Books $687.65 200 3.9 3 BULK-dc3a7947
10779 Bulk Product 7e2571a0 Home & Garden $730.01 259 2.0 54 BULK-8d74f27f
10780 Bulk Product 596c7eea Toys & Games $788.50 98 2.0 61 BULK-d16e1065
10781 Bulk Product 175076af Toys & Games $115.13 309 4.6 61 BULK-9aa597d0
10782 Bulk Product 20b1bc68 Toys & Games $430.77 222 2.6 35 BULK-3b597b6f
10783 Bulk Product fbc260f7 Toys & Games $85.20 375 4.8 74 BULK-6ccdaef2
10784 Bulk Product c65c6dfb Electronics $171.45 299 1.4 55 BULK-8060070f
10785 Bulk Product dc89158f Books $522.81 178 2.3 21 BULK-71471c65
10786 Bulk Product f4883459 Sports & Outdoors $786.06 58 2.3 38 BULK-5045c637
10787 Bulk Product 1058480a Clothing $459.27 333 1.6 69 BULK-4d62c10d
10788 Bulk Product 97d6d4a7 Home & Garden $594.12 479 1.2 71 BULK-a0aa4a08
10789 Bulk Product 73a60d60 Clothing $58.43 238 4.3 80 BULK-c27d0b38
10790 Bulk Product f8726797 Sports & Outdoors $403.09 400 0.1 99 BULK-6731ed41
10791 Bulk Product fe4b5e5e Toys & Games $835.14 164 4.2 85 BULK-4422fd85
10792 Bulk Product 39f96ca3 Toys & Games $134.45 40 1.7 18 BULK-9a4e218d
10793 Bulk Product f3002dba Sports & Outdoors $535.32 166 3.4 78 BULK-88de01d3
10794 Bulk Product e585f6d4 Toys & Games $122.91 45 0.1 56 BULK-2b00a8c2
10795 Bulk Product 8de54108 Sports & Outdoors $952.05 455 4.8 0 BULK-5823d41f
10796 Bulk Product 3aee4f06 Clothing $517.22 399 4.1 62 BULK-ec362883
10797 Bulk Product 309cb7d7 Sports & Outdoors $146.63 35 2.2 48 BULK-092f82af
10798 Bulk Product 9be48693 Books $523.83 245 4.6 39 BULK-4a9fa43e
10799 Bulk Product b585e8dd Home & Garden $359.14 124 0.4 84 BULK-d2a0aede
10800 Bulk Product fa79b8de Home & Garden $879.23 425 3.0 68 BULK-912172b0
10801 Bulk Product fbd4a22b Toys & Games $779.12 451 4.3 2 BULK-bc18ba98
10802 Bulk Product 73d4f161 Sports & Outdoors $928.05 85 4.6 51 BULK-c38570a5
10803 Bulk Product 81bbdec7 Electronics $763.44 252 1.6 70 BULK-feea642d
10804 Bulk Product 1c3dc6b6 Toys & Games $760.43 327 3.5 48 BULK-a69bc7ff
10805 Bulk Product 0886aa48 Books $573.79 316 0.1 92 BULK-5bdffd02
10806 Bulk Product c2c29293 Clothing $496.23 90 1.0 35 BULK-31169a29
10807 Bulk Product 2bb623da Books $460.15 53 0.7 87 BULK-e5e3fd57
10808 Bulk Product 1720825b Books $42.00 435 2.8 10 BULK-5caf14de
10809 Bulk Product 6b6a8224 Clothing $814.44 254 3.2 41 BULK-41f8499d
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