Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

34 ms

Page Size

50

Current Page

313 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 313 Results Showing 15601 - 15650 of 24441

ID Name Category Price Stock Rating Reviews SKU
16160 Bulk Product 5d7baeff Home & Garden $415.15 253 2.2 90 BULK-4abaad2d
16161 Bulk Product be288871 Electronics $777.09 87 2.3 22 BULK-24e7434d
16162 Bulk Product e6d534ba Electronics $117.13 131 1.0 39 BULK-a6af022c
16163 Bulk Product a0b02ee2 Books $461.67 238 1.0 84 BULK-dd6553d1
16164 Bulk Product bbf021a4 Clothing $1,003.49 408 1.4 53 BULK-74d46c6d
16165 Bulk Product af424950 Clothing $36.28 498 4.6 81 BULK-88c7f0e1
16166 Bulk Product 6705e436 Clothing $722.67 229 4.4 53 BULK-e6d76c1b
16167 Bulk Product 855ad151 Home & Garden $874.03 482 1.2 15 BULK-b32443ae
16168 Bulk Product 54b95fb4 Electronics $81.87 84 4.9 98 BULK-a39ff005
16169 Bulk Product 10740746 Home & Garden $618.27 255 4.8 86 BULK-3e67e0e6
16170 Bulk Product 30e87a20 Toys & Games $637.28 119 2.7 33 BULK-1c852f51
16171 Bulk Product 104b326c Toys & Games $377.26 109 1.7 99 BULK-0dd13ab3
16172 Bulk Product e84de23c Toys & Games $198.05 320 2.4 91 BULK-c1e9336a
16173 Bulk Product 3645c4ea Books $778.32 97 0.8 28 BULK-4ce667a7
16174 Bulk Product 61350be1 Home & Garden $248.16 130 4.6 59 BULK-ffee28d0
16175 Bulk Product 055ed5d0 Books $708.93 237 2.3 9 BULK-81f41729
16176 Bulk Product d0630462 Home & Garden $463.36 138 0.6 29 BULK-6f4c1874
16177 Bulk Product a9ddf62e Books $916.10 39 0.1 68 BULK-6e0bc259
16178 Bulk Product 9daba256 Toys & Games $461.85 434 1.4 66 BULK-a97b56d2
16179 Bulk Product af9b889f Home & Garden $145.54 417 2.3 5 BULK-0bd5db03
16180 Bulk Product dd26c6b9 Toys & Games $838.59 276 4.8 47 BULK-f6e9ecb1
16181 Bulk Product cfbe0ce6 Home & Garden $390.85 299 1.8 8 BULK-7b78beb2
16182 Bulk Product f4903140 Toys & Games $507.83 264 0.8 35 BULK-6297c41f
16183 Bulk Product d95aa044 Sports & Outdoors $940.81 135 4.6 8 BULK-80f5c331
16184 Bulk Product 4d1fe7cd Sports & Outdoors $444.53 274 4.0 19 BULK-77e05049
16185 Bulk Product 3d31bf9d Toys & Games $12.37 492 3.7 54 BULK-06d887ef
16186 Bulk Product 3db71040 Home & Garden $267.40 190 3.1 0 BULK-0fc77337
16187 Bulk Product dab3d42d Books $409.05 30 2.0 8 BULK-58664b04
16188 Bulk Product d3026bf1 Home & Garden $813.74 219 1.4 51 BULK-24a7db57
16189 Bulk Product 14ceb246 Toys & Games $132.29 278 0.1 93 BULK-95855935
16190 Bulk Product 54aa4210 Books $902.42 311 2.4 43 BULK-cf386219
16191 Bulk Product d4426c6e Books $777.03 236 4.0 5 BULK-128b799d
16192 Bulk Product 09385ec9 Clothing $479.40 93 2.9 61 BULK-1b77249e
16193 Bulk Product 0d5eca35 Toys & Games $477.03 171 3.0 29 BULK-a412d360
16194 Bulk Product d76ae05f Clothing $23.06 67 3.5 57 BULK-dd274cc8
16195 Bulk Product f39ff8c2 Books $866.58 312 1.6 7 BULK-d98f87d6
16196 Bulk Product 9db99b16 Electronics $213.17 468 4.6 20 BULK-a408dfed
16197 Bulk Product 1a3cc789 Books $725.65 299 0.2 13 BULK-061becbb
16198 Bulk Product 754ae368 Books $964.66 13 4.0 19 BULK-f80ec3f4
16199 Bulk Product 9f5d8572 Home & Garden $687.53 132 1.7 68 BULK-63beb459
16200 Bulk Product b6a19087 Toys & Games $953.86 32 1.1 48 BULK-019ecafb
16201 Bulk Product ba35f7fe Electronics $948.15 22 4.9 26 BULK-fee03da0
16202 Bulk Product 0efaf83e Home & Garden $567.18 325 4.7 10 BULK-b1569e17
16203 Bulk Product 3d450496 Clothing $916.68 338 2.2 90 BULK-38c98ab2
16204 Bulk Product 7c43d58c Books $794.37 285 3.4 79 BULK-70788fa7
16205 Bulk Product 1db89d4a Sports & Outdoors $287.83 257 2.8 56 BULK-373ec2f8
16206 Bulk Product 537f322a Electronics $99.32 470 1.3 72 BULK-a005c8d0
16207 Bulk Product 6e8ce6a8 Books $872.59 401 0.3 52 BULK-df03b67f
16208 Bulk Product 3176f3c3 Clothing $763.44 390 0.1 24 BULK-03af6f95
16209 Bulk Product 8800e8cc Books $697.12 486 1.6 33 BULK-348f1d8e
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