Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

19 ms

Page Size

50

Current Page

453 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 453 Results Showing 22601 - 22650 of 24441

ID Name Category Price Stock Rating Reviews SKU
23160 Bulk Product 7e3b23b0 Sports & Outdoors $810.12 393 0.0 47 BULK-ce0a5568
23161 Bulk Product 7feb400d Clothing $688.81 259 3.3 64 BULK-df564382
23162 Bulk Product 62e61184 Clothing $618.06 195 3.0 36 BULK-7a738381
23163 Bulk Product 746ccf3e Sports & Outdoors $790.82 124 2.3 14 BULK-1c6ce9f9
23164 Bulk Product dc233b65 Home & Garden $198.41 349 0.2 13 BULK-1d793b8f
23165 Bulk Product 2b97ee58 Electronics $848.43 444 2.8 76 BULK-714eb07a
23166 Bulk Product 21ddbc13 Toys & Games $684.95 104 1.0 80 BULK-69d005d4
23167 Bulk Product 093b1938 Toys & Games $209.88 414 1.0 48 BULK-3e573d86
23168 Bulk Product c10574b1 Home & Garden $708.23 55 0.1 0 BULK-476f286f
23169 Bulk Product 78516698 Clothing $823.48 323 2.6 4 BULK-8507cec3
23170 Bulk Product fc4584de Toys & Games $678.94 221 0.9 99 BULK-fc6a9994
23171 Bulk Product 40e5ce16 Electronics $95.64 359 1.9 49 BULK-300167e1
23172 Bulk Product 791f5e05 Toys & Games $622.24 257 4.9 34 BULK-1eb4906d
23173 Bulk Product cad6a3d6 Toys & Games $990.80 310 2.7 0 BULK-6db55ff6
23174 Bulk Product ad04353b Electronics $573.26 212 1.7 21 BULK-69717ee4
23175 Bulk Product a62a75b5 Sports & Outdoors $124.87 495 0.6 34 BULK-87ca5519
23176 Bulk Product 8a8b9fa8 Books $591.46 369 2.5 19 BULK-a04ca506
23177 Bulk Product 4295cc87 Toys & Games $739.16 271 3.5 39 BULK-fd85fb47
23178 Bulk Product 91caf3f7 Home & Garden $560.93 134 0.9 8 BULK-44350661
23179 Bulk Product 376ffcaf Electronics $327.24 229 4.1 28 BULK-5a9c6aee
23180 Bulk Product 9be2a5e4 Books $756.43 212 2.1 37 BULK-e144ce57
23181 Bulk Product ccd1d594 Toys & Games $216.17 82 0.1 51 BULK-8f94e8ad
23182 Bulk Product 9158ef77 Clothing $359.84 104 2.8 47 BULK-3df58d36
23183 Bulk Product a3649c70 Home & Garden $780.31 213 2.4 13 BULK-5125af49
23184 Bulk Product 6fe3dd2a Electronics $833.89 291 0.6 95 BULK-aa442769
23185 Bulk Product 2bed42ba Clothing $470.39 388 3.5 12 BULK-c42d59d6
23186 Bulk Product a2780aec Home & Garden $686.14 5 2.1 14 BULK-2462c4bb
23187 Bulk Product 121a822c Books $108.28 391 0.0 33 BULK-5aef2528
23188 Bulk Product fe93df36 Toys & Games $658.08 433 4.2 49 BULK-a7122441
23189 Bulk Product e2fe900e Sports & Outdoors $665.15 57 4.1 55 BULK-6ccfa509
23190 Bulk Product a08358e7 Home & Garden $626.32 277 3.9 31 BULK-e6d02ee2
23191 Bulk Product ed28605a Home & Garden $756.38 190 1.3 84 BULK-01611a27
23192 Bulk Product a13f6c03 Home & Garden $810.02 133 1.3 35 BULK-2a40b5f8
23193 Bulk Product 1dfebcbc Books $339.72 448 3.3 87 BULK-98159e33
23194 Bulk Product 458ceb80 Toys & Games $711.23 172 1.0 81 BULK-1715e3c5
23195 Bulk Product 8f2c72ce Sports & Outdoors $952.20 189 2.1 76 BULK-9fbf5873
23196 Bulk Product 13eab8bc Toys & Games $167.74 80 0.8 41 BULK-bdf77415
23197 Bulk Product d0e8bd2b Home & Garden $456.44 9 2.7 13 BULK-81b82a21
23198 Bulk Product e9d665a3 Toys & Games $504.83 85 2.9 97 BULK-16dd6496
23199 Bulk Product 503fa9c7 Toys & Games $619.72 202 3.3 10 BULK-177412d3
23200 Bulk Product 29b410fd Electronics $982.45 294 2.3 11 BULK-2ba7b266
23201 Bulk Product c2aa8abb Toys & Games $455.00 81 0.0 94 BULK-8b9d2ed7
23202 Bulk Product eac53520 Sports & Outdoors $779.70 263 1.3 60 BULK-bae22f1d
23203 Bulk Product 418b3cea Toys & Games $965.83 365 1.6 15 BULK-8074d2bc
23204 Bulk Product 652939b0 Home & Garden $847.29 304 2.1 68 BULK-7e32a8d4
23205 Bulk Product 3a33b684 Books $292.36 66 3.8 98 BULK-1c40a7fb
23206 Bulk Product 4fe6eac9 Electronics $790.18 98 1.0 93 BULK-29ee879d
23207 Bulk Product 0b9c77d3 Sports & Outdoors $900.35 460 1.7 3 BULK-33ad37aa
23208 Bulk Product 622f2986 Electronics $844.29 490 0.3 65 BULK-9ad55fa4
23209 Bulk Product c8381881 Books $634.88 446 1.4 9 BULK-d7f4a871
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