Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

35 ms

Page Size

50

Current Page

466 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 466 Results Showing 23251 - 23300 of 24441

ID Name Category Price Stock Rating Reviews SKU
23810 Bulk Product 54b31a98 Home & Garden $706.43 230 4.8 92 BULK-23e3c246
23811 Bulk Product 653ae369 Clothing $215.36 380 4.6 25 BULK-53604f5d
23812 Bulk Product 850b000e Sports & Outdoors $808.24 348 4.9 74 BULK-08c7ae64
23813 Bulk Product 465a0f85 Electronics $905.58 459 1.3 89 BULK-b00a06ea
23814 Bulk Product 963dba33 Sports & Outdoors $833.70 217 3.3 41 BULK-1f11e223
23815 Bulk Product 00f72aae Clothing $139.93 299 1.1 66 BULK-2c4cde03
23816 Bulk Product 29a32212 Toys & Games $544.18 228 0.2 9 BULK-88e06f62
23817 Bulk Product add6e14d Electronics $987.20 107 4.5 21 BULK-f17f9ab5
23818 Bulk Product 7f22410f Clothing $535.68 293 4.4 91 BULK-05439037
23819 Bulk Product 670551ee Electronics $380.53 10 4.4 61 BULK-40ca203e
23820 Bulk Product ebedf863 Clothing $332.76 283 1.5 91 BULK-f43dea59
23821 Bulk Product 0df8edff Clothing $928.97 39 3.4 1 BULK-a845d48b
23822 Bulk Product df2353f8 Books $86.69 156 3.8 73 BULK-54f3aa40
23823 Bulk Product 3207f77e Toys & Games $623.12 415 4.6 42 BULK-e0e57676
23824 Bulk Product 2e1fbb5e Books $745.81 120 0.6 50 BULK-253ca182
23825 Bulk Product 4f6e8c3b Home & Garden $164.69 366 3.7 85 BULK-7cf141be
23826 Bulk Product e94c1971 Home & Garden $942.71 464 3.4 39 BULK-c335c660
23827 Bulk Product 10bbf6f2 Books $858.84 492 2.1 8 BULK-faf4447d
23828 Bulk Product eb413854 Clothing $752.21 244 1.6 10 BULK-18d45726
23829 Bulk Product 7b61b8d3 Clothing $184.39 480 2.4 37 BULK-bc2c2f7d
23830 Bulk Product ca16d32c Electronics $234.51 399 2.0 61 BULK-860031eb
23831 Bulk Product 204c3e3c Books $121.49 227 4.9 78 BULK-07c5b053
23832 Bulk Product 166c043c Electronics $838.03 245 3.4 74 BULK-5bd93cfc
23833 Bulk Product 2b81c11f Home & Garden $849.48 91 4.6 88 BULK-22dc2cb2
23834 Bulk Product d8ba5386 Home & Garden $484.03 481 4.6 45 BULK-679b9e06
23835 Bulk Product 333ed02c Sports & Outdoors $699.72 232 0.0 23 BULK-e757dbd2
23836 Bulk Product 97e73f2a Clothing $487.35 44 0.8 77 BULK-32a1d99d
23837 Bulk Product 033ea2af Clothing $315.06 147 3.6 99 BULK-d312dab2
23838 Bulk Product f1042bb2 Sports & Outdoors $127.51 134 4.6 73 BULK-31c9bb15
23839 Bulk Product e7bb633a Books $295.95 475 4.2 69 BULK-0d11c0b8
23840 Bulk Product 369a6b52 Books $468.47 388 5.0 97 BULK-a81cc4ae
23841 Bulk Product 4f382d50 Sports & Outdoors $156.54 479 2.1 52 BULK-7dae706e
23842 Bulk Product 54337eb6 Electronics $721.93 141 4.6 14 BULK-89810dc5
23843 Bulk Product 7f2a2ae9 Sports & Outdoors $742.23 348 3.7 22 BULK-233a2586
23844 Bulk Product e461b8fb Electronics $397.35 314 3.2 88 BULK-414fa993
23845 Bulk Product fc05cde3 Clothing $274.27 373 0.1 46 BULK-ca8bda56
23846 Bulk Product 2b30e4af Home & Garden $930.13 419 0.6 27 BULK-6aa56935
23847 Bulk Product 172527ba Clothing $236.83 146 0.9 9 BULK-7d02111f
23848 Bulk Product 9e8701dc Electronics $904.75 478 0.9 73 BULK-c272f355
23849 Bulk Product 63e3a303 Electronics $360.86 0 1.3 17 BULK-68419bb4
23850 Bulk Product 9a0472de Electronics $1,006.11 347 3.2 62 BULK-466c4102
23851 Bulk Product c76ee052 Clothing $655.17 104 1.0 71 BULK-57a9cef3
23852 Bulk Product 616a329d Books $617.63 233 1.5 76 BULK-60656d43
23853 Bulk Product 4c1ea7df Electronics $757.64 327 0.9 34 BULK-8032a031
23854 Bulk Product b4a52797 Toys & Games $844.31 477 3.0 16 BULK-02a7e081
23855 Bulk Product 148ec0b2 Electronics $153.71 135 1.2 58 BULK-b0ded9ea
23856 Bulk Product 300e4ed3 Books $820.15 83 1.6 69 BULK-b016621e
23857 Bulk Product de5ce372 Clothing $139.78 9 3.0 95 BULK-94f5623e
23858 Bulk Product 6137f1c5 Home & Garden $393.55 336 1.1 23 BULK-618d5b56
23859 Bulk Product b9b3f338 Home & Garden $499.02 126 1.1 58 BULK-a10d6333
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