Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

21 ms

Page Size

50

Current Page

147 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 147 Results Showing 7301 - 7350 of 24441

ID Name Category Price Stock Rating Reviews SKU
7860 Bulk Product c43975d3 Home & Garden $673.09 79 2.9 31 BULK-80951941
7861 Bulk Product ada9678d Sports & Outdoors $813.93 50 4.2 77 BULK-1766188d
7862 Bulk Product 970c7799 Clothing $109.18 209 2.5 7 BULK-a978f34d
7863 Bulk Product 3bc0af21 Toys & Games $464.60 19 1.1 37 BULK-92436803
7864 Bulk Product 0d2cc769 Toys & Games $866.70 179 0.7 13 BULK-dd3e9eff
7865 Bulk Product f4176a61 Sports & Outdoors $418.20 329 4.5 40 BULK-2541462d
7866 Bulk Product 90e8aa47 Sports & Outdoors $834.32 197 0.5 71 BULK-4e7a251b
7867 Bulk Product 30ff651c Electronics $357.92 464 3.3 81 BULK-381c0c03
7868 Bulk Product 0a701e35 Home & Garden $898.47 262 3.6 32 BULK-0b4bd565
7869 Bulk Product ad6b32dd Home & Garden $748.25 425 3.6 49 BULK-6ab82ba7
7870 Bulk Product 79e4aee1 Sports & Outdoors $771.92 179 2.8 62 BULK-67244f86
7871 Bulk Product c1c7209f Home & Garden $568.41 151 0.8 40 BULK-ef635835
7872 Bulk Product 0d54d1fd Toys & Games $69.43 429 2.2 97 BULK-1540e5b7
7873 Bulk Product 9ebc2bf1 Home & Garden $633.91 205 4.5 65 BULK-7a223528
7874 Bulk Product 1a962e90 Toys & Games $352.63 107 4.3 3 BULK-060ca4bb
7875 Bulk Product 47887c94 Clothing $321.25 71 1.9 77 BULK-922b62c9
7876 Bulk Product 9b95e6fb Home & Garden $326.12 367 0.0 29 BULK-c214592d
7877 Bulk Product 36d6dfc7 Electronics $517.91 388 2.1 68 BULK-72e31c73
7878 Bulk Product dc971e92 Books $391.86 292 1.7 94 BULK-a217a62c
7879 Bulk Product e4a3d651 Home & Garden $155.65 107 1.0 12 BULK-fda7f117
7880 Bulk Product 6e98aa6a Clothing $287.99 137 2.2 51 BULK-02bdc15e
7881 Bulk Product 71058ac2 Electronics $710.53 11 1.5 56 BULK-0efffa36
7882 Bulk Product 01c9493a Electronics $786.80 199 1.4 25 BULK-a3534371
7883 Bulk Product d881d226 Electronics $90.34 211 0.3 7 BULK-826f7b13
7884 Bulk Product 77748146 Home & Garden $773.62 97 3.5 17 BULK-670752d6
7885 Bulk Product bfe0185c Home & Garden $360.42 58 0.6 30 BULK-bf4569d2
7886 Bulk Product 78adee87 Books $778.47 300 2.8 70 BULK-9fac1173
7887 Bulk Product 620f8c74 Clothing $180.47 284 1.1 32 BULK-3264e61c
7888 Bulk Product c4ca9421 Books $860.84 365 0.2 91 BULK-08485ebf
7889 Bulk Product 7a124446 Home & Garden $903.95 458 4.0 33 BULK-58165f92
7890 Bulk Product d6be262a Home & Garden $423.40 85 3.9 91 BULK-f81923d8
7891 Bulk Product 232bdb77 Books $688.62 229 1.5 24 BULK-07a98278
7892 Bulk Product 73850c0a Home & Garden $703.51 478 2.9 87 BULK-85d6dee2
7893 Bulk Product 6f4fac36 Home & Garden $608.50 32 2.1 81 BULK-802f35ec
7894 Bulk Product 29ea5b30 Sports & Outdoors $455.30 320 2.5 16 BULK-443367ae
7895 Bulk Product 045d3e50 Sports & Outdoors $663.59 391 2.1 3 BULK-60fcc418
7896 Bulk Product 541ba533 Sports & Outdoors $895.25 133 3.1 91 BULK-0accf48d
7897 Bulk Product 5b4abd40 Home & Garden $825.45 320 1.1 0 BULK-1c07fa50
7898 Bulk Product 4eb7d4af Books $654.86 13 1.9 12 BULK-c2ec9d0d
7899 Bulk Product b739e689 Books $232.24 459 4.3 95 BULK-cef09a72
7900 Bulk Product 8a91595d Sports & Outdoors $316.37 435 0.3 17 BULK-d3fa00f3
7901 Bulk Product d60853bc Sports & Outdoors $931.63 469 2.8 68 BULK-28f5bd14
7902 Bulk Product 2f130432 Home & Garden $775.65 139 1.1 67 BULK-a8f392b6
7903 Bulk Product f43a393a Books $381.05 14 2.8 61 BULK-5df5627a
7904 Bulk Product be9d3a28 Home & Garden $587.03 401 0.9 97 BULK-a15fbe06
7905 Bulk Product 16af017d Toys & Games $395.81 318 0.5 25 BULK-5f300586
7906 Bulk Product d214e6dd Clothing $269.53 366 0.8 41 BULK-c5e8ccea
7907 Bulk Product e856e94c Sports & Outdoors $122.66 398 4.8 28 BULK-c6be2fb3
7908 Bulk Product dc50a28d Home & Garden $698.53 19 1.9 52 BULK-c3905270
7909 Bulk Product 628f29bb Home & Garden $340.11 178 0.0 78 BULK-af2b2297
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