Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

22 ms

Page Size

50

Current Page

233 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 233 Results Showing 11601 - 11650 of 24441

ID Name Category Price Stock Rating Reviews SKU
12160 Bulk Product a2097f4d Electronics $859.93 421 4.7 26 BULK-386755e4
12161 Bulk Product 9d65de69 Sports & Outdoors $197.56 497 3.0 38 BULK-46b760ee
12162 Bulk Product b36dfcea Books $455.98 331 3.2 5 BULK-d0074787
12163 Bulk Product 8ea02ab0 Sports & Outdoors $16.30 272 4.3 93 BULK-6e59da6a
12164 Bulk Product 3a4c0f5c Toys & Games $412.15 275 4.5 62 BULK-f93be770
12165 Bulk Product 50872afb Books $919.28 34 4.0 73 BULK-d6f992e1
12166 Bulk Product 57e46bbf Home & Garden $826.74 283 3.9 21 BULK-d4f7dae4
12167 Bulk Product d5b2c73d Sports & Outdoors $687.37 205 3.8 68 BULK-6362a882
12168 Bulk Product 35dab363 Books $613.89 90 0.6 91 BULK-9d569f3c
12169 Bulk Product cd003940 Electronics $914.95 373 4.9 59 BULK-69c2b3ab
12170 Bulk Product 523e9a70 Sports & Outdoors $534.79 165 1.1 2 BULK-e2cafd23
12171 Bulk Product 6ac89aa9 Clothing $427.57 420 0.4 44 BULK-a61df72f
12172 Bulk Product 8e12c11d Toys & Games $797.68 246 1.1 13 BULK-532a3207
12173 Bulk Product e1266e01 Electronics $636.83 330 0.1 36 BULK-5cbb44d4
12174 Bulk Product 6bf507ba Sports & Outdoors $948.01 158 1.2 28 BULK-2f9378dd
12175 Bulk Product db59108c Books $817.36 473 1.7 4 BULK-cb8ba04b
12176 Bulk Product b56a4511 Books $864.17 211 2.4 18 BULK-5ed7811b
12177 Bulk Product 1ab79505 Electronics $649.10 452 0.7 66 BULK-33e0116c
12178 Bulk Product 84c17095 Sports & Outdoors $130.77 79 2.0 75 BULK-0a5865aa
12179 Bulk Product f2c3ae0e Home & Garden $271.40 462 3.6 94 BULK-a031adf7
12180 Bulk Product e053dbb7 Toys & Games $669.66 252 3.2 39 BULK-00ae5c63
12181 Bulk Product e385bcfa Toys & Games $23.64 364 0.9 59 BULK-2f982af1
12182 Bulk Product cde99991 Toys & Games $712.25 141 0.1 32 BULK-55942d0a
12183 Bulk Product 1eb2e3b3 Electronics $404.62 379 3.5 2 BULK-18f63036
12184 Bulk Product 1471e2eb Books $291.24 92 3.1 50 BULK-0a451d35
12185 Bulk Product 85db85d7 Electronics $287.98 35 1.5 20 BULK-95877a15
12186 Bulk Product 4c4f4895 Home & Garden $392.13 182 1.5 38 BULK-bc04adf5
12187 Bulk Product fd67cdb0 Clothing $217.08 207 0.6 56 BULK-7acce21c
12188 Bulk Product 4dd2ef0c Sports & Outdoors $123.15 451 4.4 1 BULK-fa97c1ad
12189 Bulk Product 9a8f6920 Books $496.86 458 1.7 39 BULK-e2521944
12190 Bulk Product c991a6ab Clothing $71.82 162 0.9 13 BULK-cf776948
12191 Bulk Product 34662708 Sports & Outdoors $998.91 176 3.9 3 BULK-c9577b4d
12192 Bulk Product a1cd8692 Clothing $216.79 164 0.2 26 BULK-b44a44eb
12193 Bulk Product af37e899 Sports & Outdoors $642.13 307 1.5 96 BULK-f7e46e4b
12194 Bulk Product ac5be68b Books $548.30 39 3.2 61 BULK-05a84979
12195 Bulk Product 36643d2e Books $722.12 109 3.5 36 BULK-bfdb0d9d
12196 Bulk Product f7d63cf9 Home & Garden $839.04 368 2.7 4 BULK-064218fb
12197 Bulk Product 98c7ed95 Home & Garden $864.64 114 2.4 50 BULK-59021396
12198 Bulk Product 2f1dd2bc Toys & Games $411.38 95 3.4 50 BULK-9f27e84c
12199 Bulk Product 100a88af Clothing $803.23 405 3.8 49 BULK-8e663ea9
12200 Bulk Product 690149f3 Sports & Outdoors $729.35 78 0.4 28 BULK-27d8f853
12201 Bulk Product 645d73f1 Toys & Games $43.97 497 1.4 42 BULK-733ae973
12202 Bulk Product fe1e52a7 Clothing $800.25 151 1.2 86 BULK-d1b53259
12203 Bulk Product 732cd11a Books $847.97 437 1.0 79 BULK-eda3e3a2
12204 Bulk Product 726ce91d Electronics $943.50 394 1.0 34 BULK-ae65f97c
12205 Bulk Product f761e05c Electronics $342.64 80 3.0 43 BULK-042585a4
12206 Bulk Product 786234a2 Sports & Outdoors $416.63 434 1.6 92 BULK-b44b660a
12207 Bulk Product d4a243d8 Clothing $482.75 179 1.5 7 BULK-fd707cca
12208 Bulk Product b5e57b23 Toys & Games $853.92 60 3.5 85 BULK-13a59b50
12209 Bulk Product 01c2c589 Electronics $769.91 151 1.4 92 BULK-ed9a742e
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