Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

17 ms

Page Size

50

Current Page

35 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 35 Results Showing 1701 - 1750 of 24441

ID Name Category Price Stock Rating Reviews SKU
1923 Professional Food & Grocery Product XL Food & Grocery $190.84 258 2.1 552 SKU-001923
1924 Super Electronics Product 2024 Electronics $788.66 44 3.3 980 SKU-001924
1926 Ultra Home & Garden Product Advanced Home & Garden $538.56 455 4.6 434 SKU-001926
1927 Elite Health & Beauty Product Plus Health & Beauty $301.21 426 1.8 282 SKU-001927
1928 Economy Food & Grocery Product Pro Food & Grocery $496.38 269 1.3 856 SKU-001928
1929 Professional Home & Garden Product Max Home & Garden $799.02 467 2.1 30 SKU-001929
1930 Economy Automotive Product Special Edition Automotive $321.08 108 4.3 977 SKU-001930
1931 Professional Home & Garden Product Special Edition Home & Garden $337.79 61 3.9 662 SKU-001931
1932 Standard Electronics Product Lite Electronics $151.53 390 1.7 18 SKU-001932
1933 Standard Books Product Max Books $252.95 192 3.4 428 SKU-001933
1934 Deluxe Toys & Games Product Lite Toys & Games $188.56 194 1.2 101 SKU-001934
1935 Professional Office Supplies Product Advanced Office Supplies $193.56 457 2.3 266 SKU-001935
1936 Deluxe Toys & Games Product Pro Toys & Games $731.74 22 4.2 705 SKU-001936
1937 Deluxe Toys & Games Product Advanced Toys & Games $758.12 499 2.9 949 SKU-001937
1938 Pro Office Supplies Product Pro Office Supplies $110.47 426 1.5 830 SKU-001938
1939 Deluxe Toys & Games Product XL Toys & Games $589.13 382 4.0 853 SKU-001939
1940 Pro Food & Grocery Product Plus Food & Grocery $569.86 412 1.1 156 SKU-001940
1941 Mega Toys & Games Product Advanced Toys & Games $191.85 254 4.3 199 SKU-001941
1942 Ultra Home & Garden Product Classic Home & Garden $226.68 287 4.1 175 SKU-001942
1943 Standard Sports & Outdoors Product Lite Sports & Outdoors $737.71 415 4.9 738 SKU-001943
1945 Deluxe Food & Grocery Product Advanced Food & Grocery $803.89 203 3.2 650 SKU-001945
1946 Ultra Electronics Product Advanced Electronics $280.16 159 4.0 931 SKU-001946
1948 Ultra Books Product 2024 Books $622.42 450 3.1 396 SKU-001948
1949 Professional Health & Beauty Product 2024 Health & Beauty $425.75 218 2.8 826 SKU-001949
1950 Super Home & Garden Product Lite Home & Garden $805.14 133 1.1 753 SKU-001950
1951 Deluxe Office Supplies Product Advanced Office Supplies $838.33 145 2.4 550 SKU-001951
1952 Elite Automotive Product Lite Automotive $85.33 247 1.7 638 SKU-001952
1954 Pro Home & Garden Product Advanced Home & Garden $614.85 243 1.9 322 SKU-001954
1955 Mega Clothing Product Lite Clothing $163.53 170 1.6 643 SKU-001955
1956 Ultra Clothing Product Max Clothing $175.75 167 3.0 167 SKU-001956
1957 Elite Health & Beauty Product Mini Health & Beauty $205.95 54 4.4 435 SKU-001957
1958 Pro Books Product XL Books $521.66 22 2.1 979 SKU-001958
1959 Mega Automotive Product 2024 Automotive $45.89 217 2.9 760 SKU-001959
1960 Premium Electronics Product 2024 Electronics $792.16 454 3.6 451 SKU-001960
1961 Premium Automotive Product Classic Automotive $248.46 72 1.2 519 SKU-001961
1962 Mega Sports & Outdoors Product Classic Sports & Outdoors $819.75 266 4.0 664 SKU-001962
1963 Ultra Toys & Games Product Mini Toys & Games $182.26 413 1.8 373 SKU-001963
1964 Pro Clothing Product XL Clothing $104.83 82 1.1 474 SKU-001964
1965 Mega Toys & Games Product Lite Toys & Games $498.86 255 2.3 141 SKU-001965
1966 Elite Electronics Product Special Edition Electronics $69.37 211 3.3 898 SKU-001966
1967 Premium Health & Beauty Product Special Edition Health & Beauty $780.00 480 1.3 175 SKU-001967
1968 Professional Health & Beauty Product Plus Health & Beauty $274.97 415 4.4 368 SKU-001968
1969 Professional Toys & Games Product Mini Toys & Games $407.27 13 4.2 602 SKU-001969
1970 Pro Clothing Product Special Edition Clothing $75.12 33 1.3 206 SKU-001970
1971 Elite Home & Garden Product Special Edition Home & Garden $865.56 410 3.7 63 SKU-001971
1972 Deluxe Electronics Product Special Edition Electronics $136.25 495 1.6 53 SKU-001972
1974 Deluxe Home & Garden Product 2024 Home & Garden $980.80 290 1.1 304 SKU-001974
1975 Super Toys & Games Product Advanced Toys & Games $756.96 245 1.4 917 SKU-001975
1976 Premium Health & Beauty Product Plus Health & Beauty $414.85 301 1.6 519 SKU-001976
1978 Pro Clothing Product Mini Clothing $544.81 309 2.8 605 SKU-001978
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