Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

1483 ms

Page Size

50

Current Page

87 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 87 Results Showing 4301 - 4350 of 24441

ID Name Category Price Stock Rating Reviews SKU
4845 Elite Food & Grocery Product Advanced Food & Grocery $78.11 194 3.6 40 SKU-004845
4846 Ultra Automotive Product 2024 Automotive $876.70 113 3.5 44 SKU-004846
4848 Deluxe Sports & Outdoors Product Max Sports & Outdoors $705.02 249 4.5 41 SKU-004848
4849 Standard Automotive Product Classic Automotive $957.93 213 3.1 58 SKU-004849
4850 Standard Food & Grocery Product Pro Food & Grocery $978.93 417 3.7 278 SKU-004850
4851 Economy Automotive Product Lite Automotive $914.25 352 3.7 408 SKU-004851
4852 Super Sports & Outdoors Product Mini Sports & Outdoors $354.58 192 2.9 399 SKU-004852
4853 Super Food & Grocery Product Pro Food & Grocery $307.37 202 2.1 309 SKU-004853
4854 Ultra Electronics Product Plus Electronics $220.76 4 2.2 697 SKU-004854
4855 Elite Sports & Outdoors Product Special Edition Sports & Outdoors $590.68 73 4.2 694 SKU-004855
4856 Pro Electronics Product XL Electronics $986.76 200 1.8 619 SKU-004856
4858 Standard Home & Garden Product Lite Home & Garden $716.29 79 4.4 414 SKU-004858
4859 Standard Food & Grocery Product Advanced Food & Grocery $939.72 384 1.9 570 SKU-004859
4860 Ultra Sports & Outdoors Product 2024 Sports & Outdoors $553.71 104 4.0 750 SKU-004860
4861 Mega Health & Beauty Product Pro Health & Beauty $448.36 169 2.4 360 SKU-004861
4863 Ultra Electronics Product Max Electronics $630.06 184 4.3 365 SKU-004863
4864 Economy Clothing Product 2024 Clothing $980.86 296 3.6 454 SKU-004864
4865 Economy Electronics Product Mini Electronics $37.26 70 3.7 24 SKU-004865
4866 Ultra Electronics Product Advanced Electronics $562.90 441 3.2 889 SKU-004866
4868 Elite Health & Beauty Product Plus Health & Beauty $899.08 397 1.6 817 SKU-004868
4869 Premium Clothing Product Special Edition Clothing $157.33 53 3.9 186 SKU-004869
4870 Premium Books Product Advanced Books $286.91 106 2.6 976 SKU-004870
4871 Premium Clothing Product Plus Clothing $184.62 406 4.5 2 SKU-004871
4872 Economy Toys & Games Product Pro Toys & Games $489.28 279 1.2 383 SKU-004872
4873 Ultra Electronics Product XL Electronics $234.60 164 4.1 871 SKU-004873
4874 Economy Books Product XL Books $240.14 117 4.8 994 SKU-004874
4875 Pro Sports & Outdoors Product XL Sports & Outdoors $825.39 449 3.4 520 SKU-004875
4876 Super Electronics Product Classic Electronics $443.59 402 3.2 957 SKU-004876
4877 Elite Food & Grocery Product Special Edition Food & Grocery $523.30 455 2.3 276 SKU-004877
4878 Economy Electronics Product Mini Electronics $353.37 210 2.9 200 SKU-004878
4879 Professional Home & Garden Product Lite Home & Garden $372.83 44 4.2 544 SKU-004879
4880 Elite Food & Grocery Product Lite Food & Grocery $131.28 32 5.0 551 SKU-004880
4881 Ultra Office Supplies Product Pro Office Supplies $996.38 400 4.4 369 SKU-004881
4882 Super Toys & Games Product 2024 Toys & Games $449.04 293 3.1 651 SKU-004882
4884 Mega Toys & Games Product Mini Toys & Games $303.34 86 4.2 3 SKU-004884
4885 Super Electronics Product Classic Electronics $891.96 311 2.4 100 SKU-004885
4886 Elite Health & Beauty Product Classic Health & Beauty $115.58 13 2.2 372 SKU-004886
4887 Elite Home & Garden Product Advanced Home & Garden $313.91 111 2.9 304 SKU-004887
4888 Deluxe Office Supplies Product Lite Office Supplies $235.46 315 3.2 855 SKU-004888
4889 Standard Clothing Product Advanced Clothing $726.44 123 4.7 84 SKU-004889
4890 Elite Books Product Plus Books $728.40 197 4.6 533 SKU-004890
4891 Deluxe Electronics Product Plus Electronics $284.31 428 4.7 568 SKU-004891
4892 Professional Toys & Games Product Plus Toys & Games $159.12 136 2.2 859 SKU-004892
4893 Professional Home & Garden Product XL Home & Garden $394.55 255 3.2 892 SKU-004893
4894 Economy Electronics Product Lite Electronics $304.52 108 2.3 153 SKU-004894
4895 Super Clothing Product Mini Clothing $640.86 203 3.5 602 SKU-004895
4897 Ultra Office Supplies Product Classic Office Supplies $360.86 3 2.3 260 SKU-004897
4898 Elite Electronics Product Pro Electronics $67.10 388 4.2 672 SKU-004898
4899 Mega Automotive Product 2024 Automotive $47.91 9 3.0 54 SKU-004899
4900 Deluxe Home & Garden Product XL Home & Garden $331.68 346 3.9 71 SKU-004900
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