Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

58 ms

Page Size

50

Current Page

389 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 389 Results Showing 19401 - 19450 of 24441

ID Name Category Price Stock Rating Reviews SKU
19960 Bulk Product e572473d Home & Garden $471.91 48 0.6 48 BULK-21b29a0d
19961 Bulk Product 3760c5a4 Electronics $56.43 488 4.5 45 BULK-0f7156a2
19962 Bulk Product f64c67e2 Clothing $418.55 410 0.1 81 BULK-78f0240c
19963 Bulk Product aaf43dd1 Sports & Outdoors $817.24 166 3.6 97 BULK-185439dd
19964 Bulk Product 74b140f2 Clothing $205.21 489 3.5 59 BULK-fa6b7693
19965 Bulk Product a269ec06 Books $765.01 137 1.3 20 BULK-48d46322
19966 Bulk Product 262858ee Toys & Games $516.49 179 0.4 18 BULK-8294ddef
19967 Bulk Product d2805924 Clothing $40.92 34 0.2 1 BULK-83946c9e
19968 Bulk Product cb66eef1 Electronics $1,001.66 161 0.0 91 BULK-aef4e24c
19969 Bulk Product 00a139b0 Home & Garden $998.32 357 0.3 34 BULK-6b079f84
19970 Bulk Product 1c6d0671 Sports & Outdoors $208.96 217 0.3 78 BULK-4fd7f486
19971 Bulk Product 3ba25550 Toys & Games $859.04 416 0.8 22 BULK-b455d1c3
19972 Bulk Product 099731ac Toys & Games $186.14 328 4.1 97 BULK-971be1be
19973 Bulk Product 296ef73e Electronics $875.69 443 3.3 96 BULK-46d5a6b9
19974 Bulk Product c2eef546 Sports & Outdoors $80.92 410 3.7 99 BULK-ab755921
19975 Bulk Product 9437bfa4 Home & Garden $30.18 462 2.2 99 BULK-f9ce1798
19976 Bulk Product 60c0196f Electronics $532.99 261 0.9 82 BULK-fe7b898d
19977 Bulk Product f246d4ae Electronics $756.42 389 2.0 50 BULK-86a09252
19978 Bulk Product 3b847f1a Home & Garden $644.31 329 0.8 88 BULK-abfc0ff2
19979 Bulk Product 2393a121 Home & Garden $687.83 380 4.5 67 BULK-3358a191
19980 Bulk Product ebacfdb1 Sports & Outdoors $975.96 397 1.0 49 BULK-dce7f3f9
19981 Bulk Product 2710c744 Sports & Outdoors $759.98 427 0.9 28 BULK-196910cd
19982 Bulk Product 15fe9b21 Toys & Games $957.31 303 2.2 96 BULK-33063527
19983 Bulk Product b5a3e30f Sports & Outdoors $957.76 68 0.2 13 BULK-c6f2330d
19984 Bulk Product db909862 Electronics $783.40 362 1.0 9 BULK-67af2117
19985 Bulk Product 73db7995 Home & Garden $543.23 16 3.4 61 BULK-b9b76415
19986 Bulk Product 0937da8c Clothing $103.21 70 2.3 10 BULK-fc160ac3
19987 Bulk Product d28052b3 Sports & Outdoors $423.43 319 1.7 15 BULK-4cd2f5df
19988 Bulk Product 8945605b Electronics $516.64 480 3.1 23 BULK-2683c605
19989 Bulk Product d33b3a58 Books $796.20 166 3.6 50 BULK-14084116
19990 Bulk Product 2e7541ff Clothing $670.09 185 0.2 91 BULK-02400aae
19991 Bulk Product d05a3cad Books $174.34 213 1.0 58 BULK-768cd323
19992 Bulk Product 64785b55 Books $1,009.04 209 4.8 7 BULK-3b699207
19993 Bulk Product 4da01c24 Toys & Games $160.73 220 3.1 12 BULK-ad5aae45
19994 Bulk Product 56932846 Home & Garden $158.80 215 1.9 70 BULK-b8fa78aa
19995 Bulk Product f62a85d4 Clothing $384.80 342 0.7 60 BULK-c7e112b8
19996 Bulk Product 35bb2a98 Electronics $89.06 479 4.1 58 BULK-ccb2b45c
19997 Bulk Product 1b3a2326 Toys & Games $502.18 449 3.8 81 BULK-e4d47398
19998 Bulk Product f4c1a505 Sports & Outdoors $872.23 173 2.5 14 BULK-9c64cc05
19999 Bulk Product 33e2f16a Home & Garden $145.92 345 3.0 30 BULK-10e5e033
20000 Bulk Product b95c0a80 Books $474.37 176 2.0 71 BULK-3123e6f2
20001 Bulk Product 12aa90e0 Books $841.15 411 1.3 41 BULK-9cbd87af
20002 Bulk Product c749c97a Clothing $577.39 324 3.8 95 BULK-aa019948
20003 Bulk Product 20f31da9 Sports & Outdoors $254.66 135 2.3 92 BULK-c6734631
20004 Bulk Product 3ef614be Toys & Games $633.82 320 2.6 10 BULK-fce067f0
20005 Bulk Product f4e51a11 Sports & Outdoors $652.92 443 0.3 5 BULK-ad2eec88
20006 Bulk Product a2e14d36 Electronics $545.21 427 0.4 33 BULK-596bed21
20007 Bulk Product 06e5a4b9 Clothing $657.88 483 4.7 28 BULK-f3eb8bfa
20008 Bulk Product 24bc9de3 Electronics $439.33 452 2.1 29 BULK-c32d605d
20009 Bulk Product ad49034f Sports & Outdoors $934.57 140 0.2 8 BULK-921a1f12
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