Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

47 ms

Page Size

50

Current Page

206 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 206 Results Showing 10251 - 10300 of 24441

ID Name Category Price Stock Rating Reviews SKU
10810 Bulk Product 71db92d8 Sports & Outdoors $470.57 380 2.6 77 BULK-2f7b6a44
10811 Bulk Product 9c6f9021 Sports & Outdoors $883.49 477 1.2 16 BULK-5c848784
10812 Bulk Product 41c132f2 Toys & Games $795.00 1 0.7 65 BULK-79b950f0
10813 Bulk Product 0538ff06 Clothing $882.91 476 0.1 68 BULK-8a5feb97
10814 Bulk Product 782dfc6e Home & Garden $943.13 38 3.1 8 BULK-7c8dbd49
10815 Bulk Product f4db6fef Clothing $294.22 41 2.0 74 BULK-4d8f0170
10816 Bulk Product 4e8330d2 Electronics $92.63 94 2.2 19 BULK-4bc01013
10817 Bulk Product 47bd711c Sports & Outdoors $457.67 311 1.7 89 BULK-3c6f481b
10818 Bulk Product 19b4b5d8 Toys & Games $737.05 423 4.1 12 BULK-40a696b5
10819 Bulk Product c2858ce8 Home & Garden $520.49 460 3.6 65 BULK-820ba722
10820 Bulk Product c4223710 Sports & Outdoors $816.90 89 2.1 35 BULK-55d5766b
10821 Bulk Product 1faffea2 Toys & Games $113.95 480 4.7 64 BULK-292345ab
10822 Bulk Product f98c4bc6 Clothing $41.87 210 4.4 61 BULK-2e55be13
10823 Bulk Product c0b504e0 Home & Garden $393.90 365 3.2 60 BULK-3a752695
10824 Bulk Product 5ccb6ea3 Electronics $754.69 3 1.5 12 BULK-ab01217f
10825 Bulk Product 165cbfc0 Clothing $511.55 171 1.3 94 BULK-d37b8a30
10826 Bulk Product 99f2b27c Electronics $104.77 225 1.5 87 BULK-88da4ec6
10827 Bulk Product f9e19955 Clothing $400.38 249 0.7 70 BULK-7542dab1
10828 Bulk Product f7385b3c Toys & Games $784.71 425 2.1 78 BULK-b0b83cde
10829 Bulk Product 1d43a2ec Home & Garden $106.15 102 0.5 3 BULK-2741270d
10830 Bulk Product 2997521f Home & Garden $105.03 125 4.2 75 BULK-89aaf071
10831 Bulk Product 34f169b0 Toys & Games $359.92 120 3.4 30 BULK-022a3819
10832 Bulk Product 1e612d1f Sports & Outdoors $901.59 161 5.0 22 BULK-66785e7f
10833 Bulk Product d0f0308c Home & Garden $678.26 66 3.9 45 BULK-0caba583
10834 Bulk Product 4ab8225d Sports & Outdoors $284.71 173 4.3 34 BULK-f29d800e
10835 Bulk Product ffd41acd Electronics $83.83 456 0.6 74 BULK-87efbdc6
10836 Bulk Product d4331a27 Electronics $487.17 264 2.3 50 BULK-363bf807
10837 Bulk Product c478d6a7 Books $158.71 279 4.3 9 BULK-6c546e36
10838 Bulk Product f91645ee Sports & Outdoors $263.96 468 4.6 56 BULK-5652c606
10839 Bulk Product 86e59340 Books $360.36 329 2.4 58 BULK-f12880ef
10840 Bulk Product 38d14faa Home & Garden $776.29 424 4.8 54 BULK-ecff1dfb
10841 Bulk Product 32363593 Toys & Games $225.98 201 0.5 66 BULK-d1f9ebee
10842 Bulk Product 1cc21d2a Toys & Games $778.22 356 4.7 96 BULK-d0583a92
10843 Bulk Product f0c40e76 Clothing $282.54 324 3.9 37 BULK-830095c2
10844 Bulk Product 3c12e6d8 Books $234.49 403 3.1 96 BULK-b7c1694c
10845 Bulk Product 311eabb1 Books $578.06 429 1.8 43 BULK-7e218919
10846 Bulk Product 7d602bdf Toys & Games $353.17 138 1.8 50 BULK-240951ff
10847 Bulk Product 7f9796b0 Home & Garden $770.80 360 4.7 68 BULK-c2604ab7
10848 Bulk Product 3cead1b7 Toys & Games $240.11 85 4.9 23 BULK-a01d2498
10849 Bulk Product 2898e097 Electronics $102.35 467 2.8 46 BULK-154ace5a
10850 Bulk Product fb35c5ec Sports & Outdoors $965.60 373 3.8 47 BULK-54f33c83
10851 Bulk Product c009c284 Sports & Outdoors $378.08 477 1.2 49 BULK-6eddb602
10852 Bulk Product d0aeb09b Home & Garden $173.89 139 3.6 19 BULK-20d9689f
10853 Bulk Product 58dda536 Books $344.60 363 1.7 48 BULK-a0684fde
10854 Bulk Product 5100e848 Books $661.60 185 4.2 77 BULK-f32d669f
10855 Bulk Product bb4d4c4a Electronics $689.36 219 4.5 31 BULK-7080370a
10856 Bulk Product 777284f1 Clothing $343.52 328 0.6 82 BULK-9ade600d
10857 Bulk Product 6dbf78db Clothing $558.56 438 4.6 37 BULK-56471b9f
10858 Bulk Product ae91b31e Books $792.41 115 3.2 55 BULK-a799f32b
10859 Bulk Product ba540c7d Sports & Outdoors $808.07 166 1.4 91 BULK-d73a3d0a
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