Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

65 ms

Page Size

50

Current Page

255 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 255 Results Showing 12701 - 12750 of 24441

ID Name Category Price Stock Rating Reviews SKU
13260 Bulk Product edb656c1 Clothing $462.34 350 3.5 85 BULK-b001b8e9
13261 Bulk Product 8115b85e Books $687.32 321 4.4 0 BULK-57e2d72a
13262 Bulk Product 3c45fbf2 Sports & Outdoors $817.30 333 3.6 76 BULK-9d435853
13263 Bulk Product 81f07d74 Home & Garden $656.22 112 4.0 27 BULK-35320b37
13264 Bulk Product c7257ee1 Clothing $166.93 292 1.8 0 BULK-c5958005
13265 Bulk Product 385409e8 Home & Garden $260.72 288 4.8 41 BULK-05b28f1c
13266 Bulk Product a0ccc0a4 Books $912.08 219 4.4 16 BULK-b8c93450
13267 Bulk Product a1b554f9 Electronics $502.03 495 1.8 55 BULK-5e8c14df
13268 Bulk Product 57be9260 Books $719.87 233 0.4 21 BULK-af8b38c9
13269 Bulk Product 7884a3b1 Electronics $35.87 481 0.3 23 BULK-01f1e31f
13270 Bulk Product 502719be Clothing $205.30 252 3.9 79 BULK-0abc44d8
13271 Bulk Product 655688b1 Home & Garden $431.48 439 0.6 26 BULK-173d716a
13272 Bulk Product 71676be3 Clothing $576.82 470 4.3 15 BULK-bab59383
13273 Bulk Product dc9ed8ac Electronics $542.41 338 0.0 63 BULK-613aac37
13274 Bulk Product 7d405039 Home & Garden $357.35 414 1.3 92 BULK-e31b0672
13275 Bulk Product db1676f5 Electronics $526.58 216 1.4 60 BULK-807bd650
13276 Bulk Product 9ce1f4e0 Electronics $92.93 53 4.2 58 BULK-93681832
13277 Bulk Product d59ad54f Electronics $769.61 464 2.0 91 BULK-84f31254
13278 Bulk Product 52063a6e Clothing $69.10 333 0.3 96 BULK-de1418f1
13279 Bulk Product d6c5bb0d Sports & Outdoors $318.59 159 3.6 22 BULK-d6216df1
13280 Bulk Product 08049102 Electronics $89.20 396 3.9 85 BULK-2a5ab8b2
13281 Bulk Product 8ebc579b Sports & Outdoors $762.37 41 1.9 18 BULK-7957ecca
13282 Bulk Product e0d46179 Clothing $123.99 74 0.3 91 BULK-36880e76
13283 Bulk Product ec93677f Home & Garden $271.02 354 0.9 7 BULK-7674efe5
13284 Bulk Product 6656a1f0 Sports & Outdoors $926.27 322 4.4 52 BULK-4525c446
13285 Bulk Product a119b194 Books $720.71 71 3.2 69 BULK-43773f95
13286 Bulk Product 8f0938d6 Clothing $531.47 189 0.7 2 BULK-70429f1b
13287 Bulk Product 18836962 Toys & Games $520.82 262 2.1 87 BULK-613e2c74
13288 Bulk Product 36236863 Home & Garden $49.52 419 1.6 57 BULK-c3f7d474
13289 Bulk Product 905b46d8 Books $557.61 56 0.9 49 BULK-f62e6fef
13290 Bulk Product 9194fa7c Clothing $576.40 246 3.1 91 BULK-aced9b27
13291 Bulk Product 006d8cf5 Sports & Outdoors $787.15 273 4.1 88 BULK-ba2d7f01
13292 Bulk Product 329f5382 Home & Garden $106.68 21 3.0 12 BULK-24e00fdf
13293 Bulk Product 9491e85c Toys & Games $812.16 17 4.0 28 BULK-74684a1e
13294 Bulk Product 2934267e Sports & Outdoors $335.08 454 1.0 49 BULK-3ae4017c
13295 Bulk Product cbbf2dee Sports & Outdoors $987.21 413 1.1 5 BULK-a9353819
13296 Bulk Product 25cba54b Clothing $436.91 137 2.0 90 BULK-af800b63
13297 Bulk Product 5b97f9e5 Books $498.95 423 4.0 82 BULK-2155b9c0
13298 Bulk Product d862169e Toys & Games $19.71 414 1.0 19 BULK-05d13b5b
13299 Bulk Product cf256f7f Home & Garden $373.05 214 4.2 0 BULK-251e6823
13300 Bulk Product a4eef6bc Toys & Games $279.09 215 3.8 64 BULK-09419b7c
13301 Bulk Product bdb2178e Clothing $980.82 431 0.9 42 BULK-3c93d12d
13302 Bulk Product 2db36298 Home & Garden $942.41 338 1.1 19 BULK-9124d595
13303 Bulk Product eae92a5b Books $137.19 470 3.8 39 BULK-9e726162
13304 Bulk Product 1fb3ee32 Home & Garden $967.51 258 1.2 2 BULK-710d244b
13305 Bulk Product 61d822d1 Toys & Games $99.86 446 2.0 81 BULK-3070eeaf
13306 Bulk Product afd29d25 Toys & Games $505.89 15 0.5 2 BULK-1186324c
13307 Bulk Product 4f69dd17 Books $278.44 449 0.1 88 BULK-2dc20363
13308 Bulk Product 72326e65 Home & Garden $322.96 149 0.0 32 BULK-c5cfea50
13309 Bulk Product 2b6d0049 Clothing $841.01 135 0.7 95 BULK-e2bb4435
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