Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

51 ms

Page Size

50

Current Page

195 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 195 Results Showing 9701 - 9750 of 24441

ID Name Category Price Stock Rating Reviews SKU
10260 Bulk Product 34e46e82 Home & Garden $847.69 392 3.1 99 BULK-8d1b0e4f
10261 Bulk Product e44f766f Books $17.49 94 3.3 5 BULK-349225f3
10262 Bulk Product 295e75c9 Electronics $392.12 265 0.2 7 BULK-90385cb3
10263 Bulk Product 6cf2afba Sports & Outdoors $816.18 44 1.4 76 BULK-418f2d74
10264 Bulk Product 4750b15f Books $339.32 166 0.4 42 BULK-ec3071a4
10265 Bulk Product d6642c94 Clothing $427.70 393 2.5 96 BULK-cc7b4944
10266 Bulk Product 0957a8af Clothing $265.08 60 1.4 15 BULK-20f35dc7
10267 Bulk Product 6244be30 Toys & Games $55.70 320 2.6 53 BULK-901f29eb
10268 Bulk Product 98083f84 Books $14.03 258 5.0 31 BULK-195bd6fa
10269 Bulk Product 00f034ea Electronics $379.06 0 3.7 40 BULK-f6423851
10270 Bulk Product 54410339 Home & Garden $563.55 183 4.3 74 BULK-5777e691
10271 Bulk Product d503c213 Electronics $228.31 87 5.0 95 BULK-39754bc0
10272 Bulk Product 8a87cb55 Sports & Outdoors $277.25 433 4.1 22 BULK-9b40dead
10273 Bulk Product 70677df4 Clothing $144.17 237 1.0 44 BULK-e79eac78
10274 Bulk Product 87febb68 Home & Garden $720.22 240 1.4 53 BULK-21a78661
10275 Bulk Product 262c2b8e Toys & Games $260.50 33 3.3 12 BULK-f53fc7e3
10276 Bulk Product 856341b5 Clothing $80.51 354 5.0 35 BULK-f172bc31
10277 Bulk Product 3e555e35 Clothing $109.58 279 3.3 28 BULK-b8633ac8
10278 Bulk Product 80f22185 Sports & Outdoors $586.69 230 3.0 53 BULK-0c47cd72
10279 Bulk Product 1057ba06 Sports & Outdoors $877.76 262 1.9 63 BULK-f64f2115
10280 Bulk Product 82b55d3c Books $409.09 308 0.2 81 BULK-87be415c
10281 Bulk Product d4726faf Home & Garden $542.34 220 1.5 63 BULK-a81ac489
10282 Bulk Product 3fa49e3d Books $745.81 393 0.2 4 BULK-87815505
10283 Bulk Product 55dcabe1 Electronics $721.41 151 1.3 86 BULK-141fbebc
10284 Bulk Product 3bbb52b7 Sports & Outdoors $182.57 347 1.5 49 BULK-ca26af4b
10285 Bulk Product bd496fe1 Books $821.07 143 4.0 84 BULK-375c4af8
10286 Bulk Product 06c17f68 Toys & Games $918.17 108 2.4 22 BULK-1f41b98b
10287 Bulk Product 1a948566 Toys & Games $120.88 283 3.0 42 BULK-4c129380
10288 Bulk Product ad0c0e35 Books $453.58 335 0.3 5 BULK-335cd741
10289 Bulk Product 88c1c3fc Clothing $265.87 197 0.0 6 BULK-5e6ee0ad
10290 Bulk Product 91fa9bba Books $550.35 440 0.2 48 BULK-e136de17
10291 Bulk Product e42981f6 Electronics $497.73 235 2.8 94 BULK-246a7c5c
10292 Bulk Product 05fbe53e Books $199.46 448 4.7 78 BULK-d8abc6a8
10293 Bulk Product 31c9fb68 Electronics $101.03 478 0.9 73 BULK-04f29c72
10294 Bulk Product a3f4680f Toys & Games $119.19 98 2.0 28 BULK-acef328f
10295 Bulk Product 810c98bb Books $151.60 377 1.8 53 BULK-1de6ee38
10296 Bulk Product 79d7d132 Clothing $464.26 354 3.7 5 BULK-a69fb8d9
10297 Bulk Product a3c8f19e Home & Garden $711.18 207 3.5 85 BULK-47311e5e
10298 Bulk Product ca2a0509 Toys & Games $414.47 135 1.1 32 BULK-04a32eb8
10299 Bulk Product f9bad1f7 Sports & Outdoors $158.87 123 3.5 44 BULK-15b0ae5c
10300 Bulk Product 85aad116 Toys & Games $350.06 144 4.1 2 BULK-00f6c063
10301 Bulk Product c0a3791a Home & Garden $926.57 102 1.9 32 BULK-8a8e2813
10302 Bulk Product a87906ba Clothing $917.54 77 1.2 14 BULK-328456f1
10303 Bulk Product 574832d6 Sports & Outdoors $669.33 373 0.9 91 BULK-8fa0d308
10304 Bulk Product 0829c2d6 Electronics $312.53 187 3.1 61 BULK-e13abacb
10305 Bulk Product 70b6bd63 Books $886.51 422 3.8 79 BULK-3dcb4af9
10306 Bulk Product 703d096f Toys & Games $388.03 408 1.3 13 BULK-a571fb17
10307 Bulk Product d78cebcc Clothing $251.00 217 4.6 11 BULK-71e04981
10308 Bulk Product d72d75f1 Books $230.60 285 2.3 3 BULK-bbbc3738
10309 Bulk Product ab0a36dc Clothing $622.44 320 2.5 39 BULK-29883d0b
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