Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

18 ms

Page Size

50

Current Page

194 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 194 Results Showing 9651 - 9700 of 24441

ID Name Category Price Stock Rating Reviews SKU
10210 Bulk Product 1ac09637 Electronics $107.84 61 0.1 92 BULK-706ad2ac
10211 Bulk Product 08b3c82d Books $889.25 425 3.9 56 BULK-f9041784
10212 Bulk Product 61a4441b Clothing $549.75 370 4.4 57 BULK-eea62794
10213 Bulk Product 1e514d02 Sports & Outdoors $84.08 24 3.7 28 BULK-645d28f6
10214 Bulk Product 3e64aeae Sports & Outdoors $522.52 100 0.3 65 BULK-87c5188f
10215 Bulk Product 760889f3 Home & Garden $326.27 98 0.4 59 BULK-cc7d10bb
10216 Bulk Product f6f0b627 Toys & Games $792.67 278 3.2 22 BULK-54ba8905
10217 Bulk Product 5d4108c7 Home & Garden $176.66 413 1.2 93 BULK-0b7f6a60
10218 Bulk Product e5fbe284 Sports & Outdoors $896.84 164 2.8 59 BULK-22e44b86
10219 Bulk Product 1c8dc056 Books $300.49 272 3.9 76 BULK-aa64d517
10220 Bulk Product 5ecaf882 Home & Garden $166.91 335 3.3 23 BULK-eb08c217
10221 Bulk Product 741e6561 Sports & Outdoors $903.87 256 0.6 79 BULK-cae494d9
10222 Bulk Product 3051fdd8 Books $229.59 322 3.0 96 BULK-18464c99
10223 Bulk Product a6f50289 Toys & Games $104.40 99 4.2 92 BULK-650e101d
10224 Bulk Product 60d70e35 Clothing $984.19 23 2.4 71 BULK-eec0c6f1
10225 Bulk Product 7976351d Sports & Outdoors $552.94 247 4.2 44 BULK-4eda050c
10226 Bulk Product 9a2da548 Toys & Games $49.40 469 3.8 99 BULK-03916ac1
10227 Bulk Product 32244346 Clothing $158.61 316 1.2 49 BULK-1bcd8c9e
10228 Bulk Product a76ae8c0 Sports & Outdoors $309.53 374 1.6 2 BULK-3b1b6185
10229 Bulk Product e242768e Home & Garden $637.66 106 3.3 43 BULK-9c03c6e7
10230 Bulk Product 48659c6b Clothing $451.48 356 1.0 87 BULK-fb6fbc6f
10231 Bulk Product aaff5e3e Toys & Games $373.51 355 2.4 63 BULK-8d85bc8e
10232 Bulk Product 4562dcd2 Clothing $503.86 17 2.1 64 BULK-d02747ea
10233 Bulk Product de477097 Toys & Games $616.05 101 4.8 79 BULK-d3c5d283
10234 Bulk Product b39f1d48 Toys & Games $762.67 316 4.5 4 BULK-93548f82
10235 Bulk Product c9c2611f Electronics $860.86 383 1.9 96 BULK-7e4b656e
10236 Bulk Product 7e086b0c Sports & Outdoors $298.79 43 1.0 73 BULK-50fc4ccc
10237 Bulk Product 11cba711 Home & Garden $587.44 191 2.8 72 BULK-996bde4a
10238 Bulk Product 55750478 Home & Garden $498.90 23 1.0 81 BULK-5de07c7c
10239 Bulk Product bcb38cf4 Home & Garden $825.54 171 2.3 27 BULK-5c979eef
10240 Bulk Product 91fd3104 Toys & Games $88.76 432 4.6 30 BULK-bc939fd5
10241 Bulk Product cbc2f550 Home & Garden $859.02 318 3.5 31 BULK-cfbd8d87
10242 Bulk Product 92553691 Electronics $38.17 257 4.3 13 BULK-7a6f37fc
10243 Bulk Product 47ea56b0 Sports & Outdoors $339.90 484 4.2 27 BULK-034d1983
10244 Bulk Product fa33b2ba Home & Garden $84.36 236 3.9 59 BULK-b61ce790
10245 Bulk Product 95524e0e Clothing $759.13 299 4.1 82 BULK-9265b25d
10246 Bulk Product 0038a894 Sports & Outdoors $403.48 315 1.6 54 BULK-21b8eae8
10247 Bulk Product 0ac516aa Clothing $772.62 312 3.4 97 BULK-a7d9e19c
10248 Bulk Product 597f808e Books $178.90 261 2.1 64 BULK-b26255af
10249 Bulk Product e9a26dfb Clothing $713.45 485 4.2 7 BULK-bd918e23
10250 Bulk Product ec847099 Sports & Outdoors $984.49 30 2.0 34 BULK-ec90091a
10251 Bulk Product 45ccd930 Home & Garden $781.67 135 0.0 66 BULK-768efd4a
10252 Bulk Product ecc7d117 Toys & Games $1,006.64 251 1.5 66 BULK-d9605823
10253 Bulk Product 291e08c4 Home & Garden $536.64 480 0.8 53 BULK-52c2165e
10254 Bulk Product 725c4f1c Clothing $592.87 5 3.6 90 BULK-61ddcf67
10255 Bulk Product c68f50cc Sports & Outdoors $454.40 232 0.2 54 BULK-6910e815
10256 Bulk Product 9cf48da6 Electronics $803.18 29 3.6 27 BULK-bfe07fba
10257 Bulk Product 4e3e23eb Clothing $380.68 247 2.9 50 BULK-3c7240b3
10258 Bulk Product 03888040 Books $365.62 61 1.3 61 BULK-5feeb930
10259 Bulk Product 7c51d0d5 Clothing $161.46 227 2.6 14 BULK-343613ba
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