Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

19 ms

Page Size

50

Current Page

153 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 153 Results Showing 7601 - 7650 of 24441

ID Name Category Price Stock Rating Reviews SKU
8160 Bulk Product 192bdbcc Sports & Outdoors $899.89 208 4.4 49 BULK-b315f842
8161 Bulk Product 97e6b678 Sports & Outdoors $1,003.91 94 1.8 41 BULK-04f5f26a
8162 Bulk Product 89b08803 Sports & Outdoors $645.92 447 3.2 25 BULK-f2582f1c
8163 Bulk Product 9bbb31dd Clothing $1,003.75 374 0.5 12 BULK-0dd7f2e3
8164 Bulk Product e695de76 Toys & Games $185.64 469 1.0 57 BULK-65d4e216
8165 Bulk Product c1b36222 Sports & Outdoors $29.70 383 0.8 4 BULK-9d54d370
8166 Bulk Product 7051abc2 Books $60.58 436 1.9 3 BULK-064daf3f
8167 Bulk Product 99889e9b Home & Garden $678.99 209 2.1 74 BULK-1738a694
8168 Bulk Product b4874506 Electronics $234.41 129 3.0 46 BULK-6b1666a8
8169 Bulk Product e1abd34f Books $936.26 471 4.2 95 BULK-d67b7dd6
8170 Bulk Product 0433309c Sports & Outdoors $401.50 269 1.3 52 BULK-60983108
8171 Bulk Product 45ed614e Clothing $506.76 94 2.2 73 BULK-45fac731
8172 Bulk Product bd821867 Sports & Outdoors $111.27 46 3.6 56 BULK-9ed08454
8173 Bulk Product 2d4b5f59 Toys & Games $931.49 427 4.7 54 BULK-2aa6eee4
8174 Bulk Product 6b02e66f Home & Garden $638.77 486 2.8 99 BULK-a0a02146
8175 Bulk Product c5cf4eed Toys & Games $534.94 18 1.6 46 BULK-f4aa377b
8176 Bulk Product 96bf8b61 Clothing $675.32 40 4.3 53 BULK-449164bf
8177 Bulk Product 04297698 Books $205.21 446 4.8 25 BULK-0deddc0d
8178 Bulk Product 14ff637a Books $854.72 431 2.4 8 BULK-6cb273cd
8179 Bulk Product 8a8ac9aa Electronics $301.66 456 3.5 85 BULK-114fd1ea
8180 Bulk Product 9083a4cd Electronics $463.85 125 1.2 60 BULK-1c06a734
8181 Bulk Product 563743fa Sports & Outdoors $820.80 128 4.9 21 BULK-f750156a
8182 Bulk Product 27a9b600 Home & Garden $1,007.91 173 2.7 68 BULK-b4445064
8183 Bulk Product 90275e4a Books $242.29 142 4.0 62 BULK-cbdf5fc8
8184 Bulk Product de4ae29c Home & Garden $845.61 332 0.3 17 BULK-4d83a5be
8185 Bulk Product 3bd4b8f5 Sports & Outdoors $25.54 237 4.8 5 BULK-b5f24054
8186 Bulk Product a23a5af6 Books $681.11 23 4.6 48 BULK-b14dd2a7
8187 Bulk Product fd97111e Toys & Games $86.15 34 4.6 12 BULK-20caa535
8188 Bulk Product c14d23d5 Home & Garden $611.12 126 3.0 22 BULK-f088764c
8189 Bulk Product ee535e5e Home & Garden $308.62 472 2.3 59 BULK-e25cb533
8190 Bulk Product e7934b44 Sports & Outdoors $22.39 90 3.4 79 BULK-916a3e23
8191 Bulk Product b7ab1c91 Electronics $367.02 111 3.6 72 BULK-702cdba0
8192 Bulk Product a030c6bd Clothing $438.17 476 4.2 68 BULK-63c2210b
8193 Bulk Product 5db17b91 Electronics $382.44 13 3.9 34 BULK-1b2e3a88
8194 Bulk Product c0191e5b Toys & Games $618.71 402 4.6 47 BULK-44bb467c
8195 Bulk Product 8a94686f Home & Garden $975.30 406 0.5 81 BULK-013a7843
8196 Bulk Product 21b71cf0 Electronics $218.24 39 4.7 86 BULK-d88c09df
8197 Bulk Product c7604300 Books $431.08 220 0.0 83 BULK-47266a8f
8198 Bulk Product c49f9579 Sports & Outdoors $661.45 3 0.1 3 BULK-745177d0
8199 Bulk Product 5961dec3 Toys & Games $134.43 406 3.6 29 BULK-c9a6bd90
8200 Bulk Product 9ca0c6ac Clothing $539.49 456 0.4 69 BULK-fc3f8969
8201 Bulk Product f26244c4 Electronics $710.54 284 3.1 39 BULK-51eaf3f5
8202 Bulk Product c3a19d83 Electronics $865.57 305 0.2 83 BULK-3d136afd
8203 Bulk Product 7ea3ce42 Clothing $630.08 57 2.1 84 BULK-a8943006
8204 Bulk Product f1100a73 Electronics $939.78 80 0.3 5 BULK-5707652a
8205 Bulk Product 54ad700d Home & Garden $55.79 135 3.3 81 BULK-f2d67128
8206 Bulk Product 5f9f91cb Electronics $464.51 351 1.0 43 BULK-4848e516
8207 Bulk Product 63a5637f Sports & Outdoors $13.52 380 2.3 72 BULK-38505ba9
8208 Bulk Product 32b61c0d Clothing $690.37 101 3.1 14 BULK-307ce6a3
8209 Bulk Product 2ec6092f Electronics $593.92 457 1.5 38 BULK-b0a736f0
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