Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

43 ms

Page Size

50

Current Page

56 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 56 Results Showing 2751 - 2800 of 24441

ID Name Category Price Stock Rating Reviews SKU
3083 Standard Automotive Product Plus Automotive $119.95 102 1.1 644 SKU-003083
3084 Standard Sports & Outdoors Product Pro Sports & Outdoors $462.01 327 1.4 951 SKU-003084
3085 Standard Automotive Product Plus Automotive $807.00 175 2.4 287 SKU-003085
3086 Super Automotive Product Advanced Automotive $278.40 363 3.1 845 SKU-003086
3087 Professional Sports & Outdoors Product Plus Sports & Outdoors $94.70 44 4.6 142 SKU-003087
3088 Premium Office Supplies Product Special Edition Office Supplies $506.51 487 2.2 739 SKU-003088
3089 Economy Clothing Product Plus Clothing $25.78 277 3.2 227 SKU-003089
3090 Economy Books Product Plus Books $692.82 237 1.6 936 SKU-003090
3091 Economy Home & Garden Product Classic Home & Garden $783.50 132 4.8 918 SKU-003091
3092 Deluxe Electronics Product Max Electronics $680.91 384 3.1 880 SKU-003092
3093 Professional Electronics Product Classic Electronics $438.48 466 3.2 908 SKU-003093
3094 Standard Sports & Outdoors Product Pro Sports & Outdoors $307.66 44 1.3 716 SKU-003094
3095 Elite Food & Grocery Product XL Food & Grocery $194.48 42 2.6 993 SKU-003095
3097 Mega Sports & Outdoors Product Classic Sports & Outdoors $55.73 71 4.3 198 SKU-003097
3098 Mega Office Supplies Product Lite Office Supplies $234.04 342 1.1 862 SKU-003098
3099 Ultra Sports & Outdoors Product Special Edition Sports & Outdoors $86.25 388 3.1 562 SKU-003099
3100 Mega Automotive Product Lite Automotive $513.07 95 4.1 387 SKU-003100
3102 Economy Health & Beauty Product Mini Health & Beauty $657.67 6 3.8 112 SKU-003102
3103 Ultra Food & Grocery Product XL Food & Grocery $372.72 138 3.0 467 SKU-003103
3104 Premium Electronics Product 2024 Electronics $261.30 207 1.9 582 SKU-003104
3105 Elite Sports & Outdoors Product Special Edition Sports & Outdoors $655.04 49 3.5 226 SKU-003105
3106 Professional Health & Beauty Product Classic Health & Beauty $698.56 226 2.0 688 SKU-003106
3107 Mega Health & Beauty Product Advanced Health & Beauty $945.70 425 1.3 887 SKU-003107
3108 Elite Automotive Product Classic Automotive $242.57 82 2.3 481 SKU-003108
3109 Super Office Supplies Product Mini Office Supplies $46.35 170 3.2 87 SKU-003109
3111 Deluxe Home & Garden Product Classic Home & Garden $499.92 120 1.3 673 SKU-003111
3112 Ultra Books Product Pro Books $408.75 263 4.7 631 SKU-003112
3113 Standard Home & Garden Product Special Edition Home & Garden $364.54 218 2.0 499 SKU-003113
3114 Elite Clothing Product Plus Clothing $205.11 135 3.3 522 SKU-003114
3115 Super Automotive Product Plus Automotive $960.32 92 3.5 459 SKU-003115
3116 Premium Electronics Product Classic Electronics $290.00 279 3.4 422 SKU-003116
3117 Ultra Health & Beauty Product 2024 Health & Beauty $792.64 341 2.2 301 SKU-003117
3118 Premium Electronics Product Special Edition Electronics $233.76 121 4.7 101 SKU-003118
3119 Elite Clothing Product Mini Clothing $405.48 119 2.5 607 SKU-003119
3120 Premium Sports & Outdoors Product Special Edition Sports & Outdoors $410.55 235 3.5 302 SKU-003120
3121 Elite Automotive Product Mini Automotive $861.89 450 2.4 322 SKU-003121
3122 Premium Automotive Product Advanced Automotive $165.93 159 1.5 387 SKU-003122
3123 Premium Health & Beauty Product Mini Health & Beauty $927.96 483 2.6 51 SKU-003123
3124 Super Toys & Games Product Lite Toys & Games $629.27 5 1.5 355 SKU-003124
3125 Mega Office Supplies Product Classic Office Supplies $662.30 488 1.3 283 SKU-003125
3127 Economy Food & Grocery Product Plus Food & Grocery $472.15 464 2.9 694 SKU-003127
3128 Ultra Health & Beauty Product 2024 Health & Beauty $262.13 313 3.8 716 SKU-003128
3129 Standard Health & Beauty Product Mini Health & Beauty $523.80 89 4.6 562 SKU-003129
3130 Standard Toys & Games Product Plus Toys & Games $114.58 371 2.8 726 SKU-003130
3131 Super Health & Beauty Product Lite Health & Beauty $449.81 209 4.7 847 SKU-003131
3132 Premium Clothing Product Lite Clothing $571.50 304 1.4 241 SKU-003132
3133 Premium Sports & Outdoors Product Lite Sports & Outdoors $745.32 375 2.1 134 SKU-003133
3134 Mega Automotive Product Pro Automotive $388.29 196 3.0 734 SKU-003134
3135 Super Books Product 2024 Books $722.51 160 2.0 59 SKU-003135
3136 Economy Office Supplies Product Plus Office Supplies $566.30 138 4.7 908 SKU-003136
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