Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

22 ms

Page Size

50

Current Page

432 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 432 Results Showing 21551 - 21600 of 24441

ID Name Category Price Stock Rating Reviews SKU
22110 Bulk Product 3a66283f Electronics $604.58 387 1.8 69 BULK-90d1188a
22111 Bulk Product 68181f1c Sports & Outdoors $261.40 37 2.4 86 BULK-6df99ccb
22112 Bulk Product dc7898fe Books $193.56 189 2.6 83 BULK-47494af6
22113 Bulk Product 0ed2b095 Books $847.05 429 3.9 92 BULK-061446b9
22114 Bulk Product fc9a57f5 Toys & Games $438.15 219 0.5 85 BULK-2b5da473
22115 Bulk Product d54e96af Sports & Outdoors $109.48 361 0.7 98 BULK-cd678dc2
22116 Bulk Product 7173dabe Electronics $60.17 147 2.2 28 BULK-56cc2de4
22117 Bulk Product 69c7c557 Toys & Games $786.12 27 0.0 78 BULK-a577792a
22118 Bulk Product d2c11a18 Sports & Outdoors $46.62 482 0.5 94 BULK-d6e3c357
22119 Bulk Product 480f7286 Sports & Outdoors $859.32 404 3.1 25 BULK-9c6a51d9
22120 Bulk Product 9abfb080 Sports & Outdoors $783.00 119 1.1 14 BULK-74ebda4b
22121 Bulk Product a078a1bc Sports & Outdoors $408.15 273 1.6 42 BULK-eff7d73e
22122 Bulk Product fca63e8a Home & Garden $502.06 410 3.7 89 BULK-46cff9f6
22123 Bulk Product e2336977 Home & Garden $77.61 65 3.6 74 BULK-0a66f58f
22124 Bulk Product 0da0fc9c Toys & Games $330.23 156 1.1 52 BULK-274920ec
22125 Bulk Product 623ec5f2 Books $219.00 221 3.3 57 BULK-a596822e
22126 Bulk Product 72c352c0 Toys & Games $856.88 177 0.6 14 BULK-b440e371
22127 Bulk Product 509de5b6 Toys & Games $107.00 380 2.7 33 BULK-c384e68e
22128 Bulk Product f2d92171 Home & Garden $617.34 152 4.2 68 BULK-97a01160
22129 Bulk Product b24724a5 Books $730.85 337 3.0 12 BULK-ecfcd793
22130 Bulk Product defd50d3 Clothing $476.66 15 1.0 74 BULK-58108f47
22131 Bulk Product a0d38a1b Sports & Outdoors $931.58 294 4.7 85 BULK-0718e4e5
22132 Bulk Product 9a3dc4f1 Books $518.68 482 5.0 77 BULK-0f4c32d8
22133 Bulk Product 4edcdfd7 Clothing $723.78 167 0.8 48 BULK-f6d437c5
22134 Bulk Product fc635530 Sports & Outdoors $657.62 12 0.6 54 BULK-e2be8110
22135 Bulk Product 46a93283 Clothing $140.03 456 3.7 94 BULK-91722076
22136 Bulk Product 69955b5c Books $387.68 409 3.7 11 BULK-3efbc494
22137 Bulk Product 80baf613 Toys & Games $880.20 117 1.4 39 BULK-f47180c8
22138 Bulk Product ecf377d1 Clothing $283.74 357 3.4 67 BULK-f4fbbe2c
22139 Bulk Product 8db70f43 Sports & Outdoors $513.84 489 2.6 89 BULK-90749d9b
22140 Bulk Product 0232b5fc Clothing $898.29 481 0.4 28 BULK-61f4ddd9
22141 Bulk Product 9785a22d Home & Garden $140.53 190 1.0 43 BULK-06038946
22142 Bulk Product 7de51ad0 Clothing $27.50 450 0.9 66 BULK-f7da1b60
22143 Bulk Product c3802e3f Toys & Games $518.38 203 3.6 27 BULK-c4084dab
22144 Bulk Product fd4dc0dc Home & Garden $577.64 387 1.7 9 BULK-9c417027
22145 Bulk Product 6787ec64 Clothing $375.31 178 0.3 61 BULK-1e9e5a6a
22146 Bulk Product a5941530 Books $33.77 182 0.5 78 BULK-342985b6
22147 Bulk Product 8738adcd Books $269.61 15 4.9 72 BULK-f71e607e
22148 Bulk Product 54a84ee2 Clothing $897.56 331 1.1 72 BULK-8caf4785
22149 Bulk Product 87616a6e Toys & Games $160.86 461 3.6 68 BULK-bc6e397a
22150 Bulk Product 34e24dd4 Toys & Games $757.24 427 2.8 32 BULK-3bb37847
22151 Bulk Product 6364018a Home & Garden $496.20 406 3.2 86 BULK-88efa7d9
22152 Bulk Product 2e08bb0e Clothing $279.42 26 3.8 34 BULK-f1bfbc77
22153 Bulk Product 40f8ad40 Sports & Outdoors $19.80 144 1.5 50 BULK-d3d53a38
22154 Bulk Product 868de3c0 Books $331.35 33 0.9 55 BULK-78b84b2e
22155 Bulk Product dbb6e0c2 Toys & Games $68.25 226 1.6 67 BULK-413d47f3
22156 Bulk Product ab38992f Toys & Games $805.83 361 0.5 96 BULK-cbaa475e
22157 Bulk Product 6a481a3b Electronics $540.23 58 5.0 13 BULK-00262124
22158 Bulk Product b600ef1a Books $18.10 99 3.0 67 BULK-e41781d0
22159 Bulk Product e083d88f Sports & Outdoors $1,004.76 411 3.4 59 BULK-49ccd4d6
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