Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

8 ms

Page Size

50

Current Page

55 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 55 Results Showing 2701 - 2750 of 24441

ID Name Category Price Stock Rating Reviews SKU
3026 Ultra Toys & Games Product 2024 Toys & Games $18.12 220 4.1 758 SKU-003026
3028 Mega Books Product Pro Books $274.83 349 3.6 936 SKU-003028
3029 Elite Food & Grocery Product Classic Food & Grocery $293.32 386 2.1 988 SKU-003029
3030 Elite Books Product Classic Books $957.83 14 4.2 807 SKU-003030
3031 Standard Health & Beauty Product Pro Health & Beauty $763.32 432 4.9 246 SKU-003031
3032 Mega Health & Beauty Product Plus Health & Beauty $201.25 423 4.9 484 SKU-003032
3033 Super Sports & Outdoors Product Plus Sports & Outdoors $860.77 292 4.9 172 SKU-003033
3034 Mega Books Product Max Books $891.73 181 4.5 465 SKU-003034
3035 Ultra Books Product Plus Books $215.94 202 3.1 188 SKU-003035
3036 Premium Health & Beauty Product Special Edition Health & Beauty $106.45 245 2.7 972 SKU-003036
3037 Economy Office Supplies Product Max Office Supplies $267.97 417 3.8 331 SKU-003037
3038 Professional Health & Beauty Product 2024 Health & Beauty $474.09 434 2.1 81 SKU-003038
3039 Elite Office Supplies Product 2024 Office Supplies $881.24 113 2.1 832 SKU-003039
3040 Deluxe Home & Garden Product Special Edition Home & Garden $823.94 110 1.1 594 SKU-003040
3041 Economy Office Supplies Product 2024 Office Supplies $223.57 193 1.1 722 SKU-003041
3042 Pro Home & Garden Product Lite Home & Garden $522.14 127 1.3 687 SKU-003042
3043 Elite Food & Grocery Product Plus Food & Grocery $731.59 71 4.6 256 SKU-003043
3044 Super Automotive Product Classic Automotive $279.29 271 2.8 19 SKU-003044
3045 Economy Sports & Outdoors Product Mini Sports & Outdoors $791.22 163 2.6 434 SKU-003045
3046 Standard Sports & Outdoors Product XL Sports & Outdoors $145.60 387 4.8 673 SKU-003046
3049 Mega Toys & Games Product Special Edition Toys & Games $96.50 487 4.0 894 SKU-003049
3050 Ultra Food & Grocery Product Max Food & Grocery $714.57 275 1.4 568 SKU-003050
3051 Elite Books Product 2024 Books $553.29 308 3.0 299 SKU-003051
3052 Elite Office Supplies Product Plus Office Supplies $213.29 476 4.0 660 SKU-003052
3053 Super Office Supplies Product 2024 Office Supplies $105.70 353 2.8 356 SKU-003053
3054 Deluxe Electronics Product 2024 Electronics $253.36 159 2.2 456 SKU-003054
3055 Elite Electronics Product Lite Electronics $330.72 198 3.4 274 SKU-003055
3056 Super Food & Grocery Product Advanced Food & Grocery $255.66 279 2.6 650 SKU-003056
3057 Deluxe Electronics Product 2024 Electronics $58.64 225 3.6 338 SKU-003057
3058 Economy Health & Beauty Product XL Health & Beauty $950.15 305 2.7 569 SKU-003058
3059 Standard Toys & Games Product Advanced Toys & Games $602.59 357 2.0 741 SKU-003059
3060 Super Clothing Product Plus Clothing $40.92 205 1.3 507 SKU-003060
3061 Mega Toys & Games Product Classic Toys & Games $148.99 452 2.4 966 SKU-003061
3062 Economy Office Supplies Product Pro Office Supplies $287.42 383 3.5 129 SKU-003062
3064 Mega Food & Grocery Product Advanced Food & Grocery $792.70 389 3.1 152 SKU-003064
3065 Ultra Clothing Product Classic Clothing $813.37 451 4.0 323 SKU-003065
3066 Deluxe Clothing Product Pro Clothing $587.97 317 2.1 350 SKU-003066
3067 Standard Health & Beauty Product Max Health & Beauty $142.22 281 3.8 111 SKU-003067
3068 Super Sports & Outdoors Product Plus Sports & Outdoors $332.07 173 5.0 544 SKU-003068
3070 Deluxe Health & Beauty Product XL Health & Beauty $808.78 162 1.6 277 SKU-003070
3071 Professional Books Product Pro Books $460.34 60 4.3 751 SKU-003071
3072 Pro Home & Garden Product Classic Home & Garden $956.76 36 2.7 723 SKU-003072
3073 Professional Office Supplies Product Advanced Office Supplies $627.88 281 4.6 839 SKU-003073
3074 Ultra Food & Grocery Product Plus Food & Grocery $588.00 9 2.5 817 SKU-003074
3075 Standard Automotive Product Special Edition Automotive $113.85 475 3.8 152 SKU-003075
3076 Pro Electronics Product Max Electronics $96.93 490 4.5 80 SKU-003076
3078 Ultra Books Product Lite Books $804.45 287 1.7 854 SKU-003078
3079 Standard Electronics Product Classic Electronics $382.74 214 3.2 865 SKU-003079
3080 Ultra Home & Garden Product 2024 Home & Garden $643.65 299 3.9 663 SKU-003080
3081 Elite Food & Grocery Product Classic Food & Grocery $137.11 43 4.2 959 SKU-003081
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