Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

12 ms

Page Size

50

Current Page

327 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 327 Results Showing 16301 - 16350 of 24441

ID Name Category Price Stock Rating Reviews SKU
16860 Bulk Product f837b793 Home & Garden $531.42 165 0.0 40 BULK-e6d58f05
16861 Bulk Product 6e029869 Toys & Games $470.57 302 3.5 97 BULK-94f03276
16862 Bulk Product ae2b645e Books $793.82 459 4.2 10 BULK-541c072e
16863 Bulk Product 12a04929 Toys & Games $270.53 282 4.5 74 BULK-88d5c76c
16864 Bulk Product 6aa6ce23 Sports & Outdoors $606.50 225 1.8 77 BULK-cd23362a
16865 Bulk Product e5dbe532 Sports & Outdoors $174.41 275 0.5 46 BULK-5b7f222d
16866 Bulk Product a1ae04ce Toys & Games $131.51 241 2.4 85 BULK-b1ac767b
16867 Bulk Product 64575376 Home & Garden $819.90 446 1.2 26 BULK-19972c66
16868 Bulk Product 0a62dcce Books $377.03 32 4.1 22 BULK-b9e94dd3
16869 Bulk Product 9694ca52 Electronics $696.31 323 1.4 67 BULK-10024ee3
16870 Bulk Product 346c30e8 Sports & Outdoors $114.56 370 2.8 93 BULK-807dd641
16871 Bulk Product a498c1e6 Electronics $390.61 147 2.3 58 BULK-7decba54
16872 Bulk Product 706ecdee Sports & Outdoors $690.61 44 5.0 60 BULK-6f3dcf9d
16873 Bulk Product b4e3cfb3 Home & Garden $581.74 25 3.1 54 BULK-78c223d1
16874 Bulk Product 87966d50 Toys & Games $781.11 287 4.0 72 BULK-3e13f456
16875 Bulk Product 0fe55974 Toys & Games $600.42 111 2.7 43 BULK-52ee2f63
16876 Bulk Product 72175a12 Electronics $15.58 277 2.3 56 BULK-3677eb0a
16877 Bulk Product eb70000a Sports & Outdoors $359.84 296 4.6 28 BULK-e64ed908
16878 Bulk Product 568d24fd Books $382.57 444 1.0 44 BULK-6a9de5b4
16879 Bulk Product bc5d940e Toys & Games $199.84 36 4.5 50 BULK-efe250ed
16880 Bulk Product 56e4fcc7 Home & Garden $356.39 139 0.6 12 BULK-05b80c04
16881 Bulk Product 5fb0213b Home & Garden $641.99 86 1.3 61 BULK-ced6c479
16882 Bulk Product bdd2ddab Electronics $538.01 367 4.7 99 BULK-1bad6174
16883 Bulk Product 4f47441f Home & Garden $591.48 8 4.7 48 BULK-65e40991
16884 Bulk Product 2147f0df Sports & Outdoors $358.64 322 2.6 80 BULK-214a3257
16885 Bulk Product c5d68138 Clothing $437.85 182 4.2 18 BULK-d5a53dff
16886 Bulk Product 6d210464 Home & Garden $675.61 244 2.1 88 BULK-40d3c148
16887 Bulk Product e5e066a9 Home & Garden $127.10 232 2.2 74 BULK-0a9c6f67
16888 Bulk Product 830a6a66 Clothing $177.32 449 0.2 89 BULK-7da8f9c2
16889 Bulk Product ea80e837 Clothing $965.99 404 4.8 42 BULK-a350278e
16890 Bulk Product c70bd9cc Electronics $712.32 251 3.9 54 BULK-46423dc2
16891 Bulk Product f7ac709b Home & Garden $137.41 36 4.7 52 BULK-b590a5d4
16892 Bulk Product ba3eca00 Clothing $221.47 204 2.4 42 BULK-7feadaff
16893 Bulk Product 29f4bd7c Sports & Outdoors $102.56 66 2.8 8 BULK-75e85c47
16894 Bulk Product 3412960c Books $612.19 183 2.9 35 BULK-247b89dc
16895 Bulk Product acc2026f Toys & Games $956.40 71 2.6 18 BULK-4586b9a5
16896 Bulk Product 79b4e713 Electronics $980.83 486 4.4 10 BULK-4936770b
16897 Bulk Product 5266f7c7 Home & Garden $785.82 156 4.9 27 BULK-af0ebf31
16898 Bulk Product 714f39fe Clothing $208.18 483 2.5 81 BULK-7b3b8e26
16899 Bulk Product 4d36f064 Clothing $83.10 250 1.0 89 BULK-bec2dc3f
16900 Bulk Product 886608b1 Home & Garden $894.19 149 2.8 37 BULK-5e63eefa
16901 Bulk Product e97ecc6a Toys & Games $280.54 370 1.3 44 BULK-cdd55d9a
16902 Bulk Product 5ca38278 Toys & Games $824.67 37 0.9 98 BULK-888036c1
16903 Bulk Product bd2f2998 Clothing $970.97 219 2.9 0 BULK-32d41199
16904 Bulk Product 2c33d551 Sports & Outdoors $871.56 337 2.3 16 BULK-c7242464
16905 Bulk Product 14c944aa Home & Garden $441.91 38 2.0 3 BULK-51ef8a6b
16906 Bulk Product 5ec8089d Books $242.98 390 1.8 34 BULK-dddcbaf2
16907 Bulk Product b781e25f Books $933.74 295 4.9 41 BULK-b6afb7ac
16908 Bulk Product 1ee8cbdb Books $784.27 388 2.4 9 BULK-fdf54c6c
16909 Bulk Product 9f4738b7 Clothing $839.19 419 3.3 56 BULK-87627d46
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