Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

33 ms

Page Size

50

Current Page

372 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 372 Results Showing 18551 - 18600 of 24441

ID Name Category Price Stock Rating Reviews SKU
19110 Bulk Product 15232dbe Books $505.70 56 1.8 63 BULK-dc152e5d
19111 Bulk Product b9396b34 Sports & Outdoors $678.62 285 1.6 7 BULK-aba2b33a
19112 Bulk Product 09fb2a75 Clothing $932.22 369 4.9 18 BULK-668bc36d
19113 Bulk Product 9807cdac Home & Garden $964.99 66 4.9 3 BULK-096cf5d5
19114 Bulk Product 1098f337 Home & Garden $776.56 33 1.2 87 BULK-2ed05499
19115 Bulk Product 84e22f9f Clothing $991.56 342 2.0 48 BULK-5c37ecb5
19116 Bulk Product 421bf413 Home & Garden $861.00 482 3.6 58 BULK-99b55ab6
19117 Bulk Product 479fcec1 Sports & Outdoors $660.99 242 2.0 40 BULK-cbc7128e
19118 Bulk Product b8351e27 Toys & Games $802.47 486 4.0 26 BULK-be2c0374
19119 Bulk Product 1cb42967 Books $467.13 326 2.6 3 BULK-338f1882
19120 Bulk Product 7300b4d8 Sports & Outdoors $559.32 225 4.2 53 BULK-b60d4df2
19121 Bulk Product c48c98df Sports & Outdoors $935.44 150 1.9 52 BULK-6afd369f
19122 Bulk Product 21c91965 Electronics $981.23 23 2.6 13 BULK-de7dd695
19123 Bulk Product 464c66c1 Clothing $802.56 206 3.5 54 BULK-f5c44151
19124 Bulk Product fa481667 Home & Garden $553.05 414 4.8 81 BULK-6f3ae7e7
19125 Bulk Product 86bd694f Books $836.62 324 1.7 35 BULK-a5c1057a
19126 Bulk Product 3cb036e9 Home & Garden $618.78 44 4.0 69 BULK-ed1361b4
19127 Bulk Product 9766081d Books $470.27 298 3.9 63 BULK-3428d534
19128 Bulk Product db8f3e35 Toys & Games $199.45 136 2.9 5 BULK-e15103d1
19129 Bulk Product be84c802 Sports & Outdoors $622.62 433 3.3 59 BULK-14049628
19130 Bulk Product e0326675 Clothing $906.80 127 3.2 48 BULK-40446e56
19131 Bulk Product 356e529f Clothing $37.38 186 2.1 27 BULK-5661f025
19132 Bulk Product cf618842 Books $426.09 416 2.3 30 BULK-008a07aa
19133 Bulk Product abf7b69a Toys & Games $591.38 251 1.6 52 BULK-070414e5
19134 Bulk Product fe718513 Clothing $821.77 193 2.2 42 BULK-ec8b5017
19135 Bulk Product b68b19f7 Home & Garden $605.89 146 1.6 87 BULK-7801f66f
19136 Bulk Product 0f8f450b Clothing $842.44 153 0.1 76 BULK-1594176d
19137 Bulk Product 1546486a Sports & Outdoors $429.26 378 3.5 62 BULK-901aa937
19138 Bulk Product d4690e83 Toys & Games $82.80 66 3.5 72 BULK-e77bca14
19139 Bulk Product 961cf07d Clothing $472.28 79 3.1 5 BULK-1b7adc15
19140 Bulk Product 86f29900 Books $827.62 432 0.3 19 BULK-ab7d400b
19141 Bulk Product cead7731 Books $613.94 337 0.4 86 BULK-1be76a74
19142 Bulk Product 2c1fa9af Electronics $859.78 233 2.8 20 BULK-6505e2b5
19143 Bulk Product f25d01f9 Clothing $129.37 97 3.9 79 BULK-3a0e5900
19144 Bulk Product 1b2b5515 Home & Garden $41.59 452 2.9 7 BULK-02359008
19145 Bulk Product f27ac60d Toys & Games $693.16 35 2.3 41 BULK-05c1431a
19146 Bulk Product be45a189 Books $952.82 205 4.0 73 BULK-de3de213
19147 Bulk Product d4ec9ebf Electronics $614.29 483 2.1 75 BULK-295fd3e2
19148 Bulk Product f29aee49 Clothing $338.66 483 5.0 62 BULK-eec412b6
19149 Bulk Product 4599c3fe Electronics $981.04 0 3.5 82 BULK-faeae33e
19150 Bulk Product 7b90c9d8 Electronics $194.38 190 1.8 40 BULK-83f026a3
19151 Bulk Product 9a9306dd Sports & Outdoors $681.23 29 0.6 56 BULK-cf4cc703
19152 Bulk Product 7c079965 Sports & Outdoors $366.04 121 0.4 55 BULK-1fea07aa
19153 Bulk Product 2a682415 Electronics $536.94 492 0.0 15 BULK-3196e7fe
19154 Bulk Product 64a9e071 Home & Garden $37.86 440 3.5 95 BULK-a3bc4d94
19155 Bulk Product f17b06ca Clothing $960.24 202 2.8 49 BULK-4a28bfc1
19156 Bulk Product 1cb40013 Clothing $811.90 310 4.5 74 BULK-40eed721
19157 Bulk Product 87ff01c6 Home & Garden $954.76 146 2.3 6 BULK-483f12c8
19158 Bulk Product 5c9b1359 Toys & Games $184.81 400 1.4 53 BULK-d3a40197
19159 Bulk Product 458cf914 Electronics $915.57 43 1.3 1 BULK-cd34ffe2
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