Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

26 ms

Page Size

50

Current Page

426 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 426 Results Showing 21251 - 21300 of 24441

ID Name Category Price Stock Rating Reviews SKU
21810 Bulk Product afb97683 Toys & Games $48.78 318 4.0 59 BULK-91953aa0
21811 Bulk Product edf30d1f Home & Garden $13.81 207 3.0 96 BULK-4b3d9aba
21812 Bulk Product 7d15d19f Electronics $715.95 431 4.2 25 BULK-1f0e0712
21813 Bulk Product a0f9fffd Toys & Games $580.36 307 1.5 22 BULK-acd85a9a
21814 Bulk Product dbaaf429 Sports & Outdoors $387.28 299 1.1 42 BULK-ea7bd4cc
21815 Bulk Product 729aff5d Books $547.50 433 1.1 97 BULK-7bdb2ae1
21816 Bulk Product c610600a Clothing $224.55 405 0.2 97 BULK-0bacddbd
21817 Bulk Product 537b65f5 Sports & Outdoors $162.40 322 3.5 7 BULK-1cb1c461
21818 Bulk Product c328b89d Clothing $342.81 372 2.4 91 BULK-d701471d
21819 Bulk Product d4486093 Toys & Games $318.12 419 0.6 81 BULK-96202c50
21820 Bulk Product 6eb24ff7 Electronics $847.95 114 3.2 50 BULK-77985730
21821 Bulk Product 978cbfc9 Toys & Games $267.78 251 4.9 71 BULK-91bb883d
21822 Bulk Product a91ed610 Toys & Games $744.30 98 4.6 66 BULK-66eb7f17
21823 Bulk Product f6107d7c Books $395.94 443 0.9 85 BULK-898f8992
21824 Bulk Product 43737344 Clothing $717.29 496 3.5 98 BULK-10c422a7
21825 Bulk Product 6f51e5c6 Electronics $184.53 395 0.5 33 BULK-6d847992
21826 Bulk Product 5c961115 Home & Garden $959.16 58 2.4 67 BULK-5b801f11
21827 Bulk Product 38d1db70 Toys & Games $985.26 23 1.4 6 BULK-492a7780
21828 Bulk Product 68eea6e8 Electronics $744.63 210 4.6 22 BULK-c6081ce2
21829 Bulk Product 6767fd53 Sports & Outdoors $111.07 49 4.9 34 BULK-59aecdbe
21830 Bulk Product 4fc21aa8 Clothing $552.15 438 1.0 75 BULK-236bd80c
21831 Bulk Product 8a954c49 Books $844.61 338 4.1 86 BULK-03e7490e
21832 Bulk Product 34565005 Clothing $311.20 287 1.2 66 BULK-3e89dbaa
21833 Bulk Product 2cdd31e3 Clothing $264.95 325 3.3 44 BULK-4c2fbcb6
21834 Bulk Product b547a797 Home & Garden $811.79 203 3.6 34 BULK-9f3058af
21835 Bulk Product 2d0eb5b9 Books $817.10 232 0.1 13 BULK-b74acdb0
21836 Bulk Product 3b7a1fcf Books $245.28 299 2.7 12 BULK-d591afb3
21837 Bulk Product d94ffca8 Toys & Games $848.74 191 2.4 21 BULK-5aab8908
21838 Bulk Product 5a5fc30f Sports & Outdoors $720.44 387 4.2 41 BULK-9097f6fb
21839 Bulk Product 30c031df Home & Garden $816.18 298 3.3 87 BULK-edf6ec4a
21840 Bulk Product 7c65a805 Electronics $357.27 289 1.7 10 BULK-fc744883
21841 Bulk Product 3d150fbe Clothing $683.55 77 2.8 23 BULK-f77a7ab6
21842 Bulk Product b6139ab9 Home & Garden $833.75 253 2.4 28 BULK-cfea0c9c
21843 Bulk Product 1570f0e0 Clothing $336.53 111 0.8 87 BULK-ec51fc9d
21844 Bulk Product 938dbf2e Sports & Outdoors $904.32 178 1.3 10 BULK-8bf4bd9c
21845 Bulk Product 946a20fb Clothing $70.44 499 4.8 41 BULK-6ed8ae90
21846 Bulk Product 4bbff319 Clothing $171.41 147 3.9 53 BULK-c0fdd9da
21847 Bulk Product dc31f85f Home & Garden $964.03 346 1.7 79 BULK-c0c79c24
21848 Bulk Product d8a7e8c6 Home & Garden $576.73 200 1.4 48 BULK-565d93fb
21849 Bulk Product fae9c79c Home & Garden $568.09 414 1.3 0 BULK-aa8873de
21850 Bulk Product be509338 Sports & Outdoors $968.63 358 4.7 75 BULK-e5ee2fe7
21851 Bulk Product c44e0816 Toys & Games $752.68 253 4.5 21 BULK-2e2bf5d4
21852 Bulk Product 555e99ca Electronics $86.94 220 3.6 95 BULK-775fd57c
21853 Bulk Product c19cc763 Electronics $418.55 36 3.0 63 BULK-3f58de67
21854 Bulk Product 8c4fbcd7 Books $724.73 408 4.4 94 BULK-2b2887d0
21855 Bulk Product 8ddc7d00 Clothing $668.93 441 3.7 88 BULK-67be7a11
21856 Bulk Product 16474c60 Books $518.61 187 2.4 15 BULK-18f1c18b
21857 Bulk Product 4fb00ae2 Home & Garden $57.70 178 0.5 16 BULK-16c4681e
21858 Bulk Product d8f9108f Clothing $371.66 35 2.3 41 BULK-be6bce0c
21859 Bulk Product 0a55729f Toys & Games $90.68 167 1.0 37 BULK-224eba35
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