Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

10 ms

Page Size

50

Current Page

132 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 132 Results Showing 6551 - 6600 of 24441

ID Name Category Price Stock Rating Reviews SKU
7110 Bulk Product 39319734 Sports & Outdoors $122.67 85 1.1 44 BULK-c784156d
7111 Bulk Product c6844cd7 Toys & Games $380.34 277 3.1 81 BULK-e57d39e3
7112 Bulk Product 7a7b187f Clothing $618.20 157 0.3 71 BULK-073840a2
7113 Bulk Product 4469683e Electronics $724.61 160 3.3 6 BULK-70a836f1
7114 Bulk Product 418d43df Books $191.73 21 0.9 32 BULK-57c5d6af
7115 Bulk Product b746a64b Sports & Outdoors $367.84 315 0.2 70 BULK-37bf7ee1
7116 Bulk Product 6caefd93 Sports & Outdoors $227.87 193 4.4 54 BULK-32318e77
7117 Bulk Product e1299839 Toys & Games $275.59 48 1.9 67 BULK-56f1c143
7118 Bulk Product 1e8a3f20 Clothing $176.64 338 0.3 70 BULK-8d8b3f41
7119 Bulk Product 4b802cbc Books $121.49 104 1.0 50 BULK-3602f762
7120 Bulk Product d9d2fed7 Books $424.29 340 0.1 41 BULK-c9c63d0e
7121 Bulk Product 139fd61c Toys & Games $68.62 213 4.0 44 BULK-4f299d80
7122 Bulk Product 64e072a2 Home & Garden $452.46 163 4.4 32 BULK-6c5cbec2
7123 Bulk Product f0ec7eef Toys & Games $391.83 190 0.7 31 BULK-82d0384a
7124 Bulk Product 8cccc7c5 Home & Garden $643.34 318 4.8 92 BULK-3389985b
7125 Bulk Product 2d283579 Clothing $964.34 54 4.4 43 BULK-ab8e262e
7126 Bulk Product b06fb0bf Clothing $472.77 478 1.5 0 BULK-cc9d2a00
7127 Bulk Product 2bf6ae73 Clothing $387.43 435 2.2 22 BULK-fcc117e0
7128 Bulk Product 8e94fb4a Toys & Games $527.49 117 2.2 50 BULK-985ba14c
7129 Bulk Product 63650aa9 Toys & Games $16.55 48 3.2 34 BULK-78369598
7130 Bulk Product 3681c03b Sports & Outdoors $347.02 154 4.6 15 BULK-8762bbc3
7131 Bulk Product 24fdf7ce Electronics $793.63 168 3.8 79 BULK-3c4f58c5
7132 Bulk Product 2f33d2c4 Sports & Outdoors $151.75 305 2.1 54 BULK-dab4f932
7133 Bulk Product b4e03bfe Home & Garden $499.07 354 1.3 76 BULK-3914d99e
7134 Bulk Product 719a01e8 Toys & Games $952.43 440 0.8 29 BULK-e74d60ba
7135 Bulk Product 45d4dc0f Home & Garden $614.54 172 4.2 12 BULK-80302154
7136 Bulk Product 4dce59f6 Home & Garden $786.97 346 1.1 16 BULK-015f179d
7137 Bulk Product 507b6b48 Toys & Games $661.87 360 0.5 15 BULK-15819d47
7138 Bulk Product 7754c9e8 Clothing $990.87 52 2.3 19 BULK-622f36af
7139 Bulk Product 3abadae8 Toys & Games $426.17 286 4.3 78 BULK-4dbaa943
7140 Bulk Product a34e7b55 Books $302.82 3 0.4 47 BULK-d56949d4
7141 Bulk Product cccbbf47 Books $607.82 482 0.2 5 BULK-0afeb63f
7142 Bulk Product 45d658a8 Electronics $795.60 406 3.8 4 BULK-6fa4d58f
7143 Bulk Product 39532ad4 Electronics $376.81 285 1.2 93 BULK-791aa8b8
7144 Bulk Product 4b4f7261 Sports & Outdoors $418.68 447 0.3 19 BULK-6c09a624
7145 Bulk Product 6c966eb3 Toys & Games $836.34 112 2.0 29 BULK-d98a39c1
7146 Bulk Product 5d29f12e Clothing $896.17 90 2.0 22 BULK-77b6f112
7147 Bulk Product 7aab8855 Sports & Outdoors $204.76 87 2.5 66 BULK-199f1560
7148 Bulk Product c14a6425 Toys & Games $943.89 0 1.4 5 BULK-5ea03892
7149 Bulk Product dc5d14f0 Sports & Outdoors $239.08 331 4.0 94 BULK-88bb193b
7150 Bulk Product 27570ce2 Toys & Games $790.40 359 3.9 2 BULK-bfbdde6e
7151 Bulk Product b7986e05 Electronics $396.26 3 1.6 39 BULK-5d6222f1
7152 Bulk Product a6d4c3ce Clothing $844.61 441 2.7 62 BULK-7278f70a
7153 Bulk Product ad149cf9 Clothing $654.47 124 0.6 29 BULK-249c6108
7154 Bulk Product ee9d7703 Electronics $68.27 341 3.3 40 BULK-866846ef
7155 Bulk Product 860a8d70 Clothing $463.87 438 2.2 81 BULK-17045e36
7156 Bulk Product a71c83d1 Home & Garden $786.85 196 0.6 47 BULK-da1b4bbb
7157 Bulk Product 9ec71c28 Toys & Games $215.90 290 0.7 71 BULK-39b961ef
7158 Bulk Product 9f44b6fb Sports & Outdoors $173.26 94 5.0 9 BULK-5373786a
7159 Bulk Product 504b6a46 Electronics $270.95 297 4.4 22 BULK-ef6e02fa
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