Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

29 ms

Page Size

50

Current Page

353 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 353 Results Showing 17601 - 17650 of 24441

ID Name Category Price Stock Rating Reviews SKU
18160 Bulk Product eb7be421 Toys & Games $661.89 281 1.4 39 BULK-4e47a905
18161 Bulk Product 8d8f0fdb Electronics $538.81 196 2.6 10 BULK-9d6b041b
18162 Bulk Product 40a75e11 Electronics $519.71 477 3.0 18 BULK-59a9c21f
18163 Bulk Product cf493893 Sports & Outdoors $308.12 59 1.7 46 BULK-42e1f53b
18164 Bulk Product 47060e1f Toys & Games $545.51 221 0.4 5 BULK-d1d8f1d8
18165 Bulk Product ec6cfec5 Books $702.73 17 2.0 66 BULK-9414968f
18166 Bulk Product df2e8570 Sports & Outdoors $65.49 244 2.2 65 BULK-91e46b33
18167 Bulk Product 3f282fdc Electronics $280.94 267 0.4 22 BULK-06dd7ef0
18168 Bulk Product 95a4d292 Toys & Games $806.60 380 2.5 51 BULK-f0c667c2
18169 Bulk Product 8fccfba2 Home & Garden $382.22 491 4.4 39 BULK-3624a527
18170 Bulk Product 122a8ca6 Electronics $433.94 218 0.8 79 BULK-2c49be6d
18171 Bulk Product a38e76cb Electronics $383.55 84 1.2 4 BULK-dcccde71
18172 Bulk Product 4aa60621 Books $999.54 74 0.8 17 BULK-76561473
18173 Bulk Product d9458541 Electronics $855.06 316 3.7 66 BULK-77d109e9
18174 Bulk Product c8295ffc Sports & Outdoors $949.06 357 2.2 62 BULK-0aa16e5a
18175 Bulk Product 3730d9c0 Sports & Outdoors $205.93 29 4.2 73 BULK-ca882b8b
18176 Bulk Product b79f9cb9 Sports & Outdoors $398.52 487 4.3 10 BULK-fc04f29f
18177 Bulk Product b66c9b6d Clothing $887.76 370 0.2 9 BULK-dd790177
18178 Bulk Product a17475c9 Books $620.34 294 2.8 62 BULK-8cba4145
18179 Bulk Product 5a4bf7a9 Home & Garden $425.03 110 4.0 3 BULK-289f15b7
18180 Bulk Product dd5a4d13 Sports & Outdoors $712.29 115 4.4 61 BULK-4dbe2f5d
18181 Bulk Product 61162edf Toys & Games $89.49 217 2.0 86 BULK-cf6b5119
18182 Bulk Product c985f5d0 Sports & Outdoors $76.56 16 0.5 69 BULK-ad402dbb
18183 Bulk Product 0d1f47fe Books $151.34 203 3.9 11 BULK-0d007d5f
18184 Bulk Product d42b2cf2 Sports & Outdoors $453.79 8 2.5 90 BULK-368befc5
18185 Bulk Product c114197e Clothing $317.80 334 3.8 57 BULK-5bb62f20
18186 Bulk Product 34f632f5 Books $441.37 447 0.3 81 BULK-c5974f0d
18187 Bulk Product b043764d Books $444.22 197 5.0 2 BULK-e716aba8
18188 Bulk Product d4c2466a Clothing $827.24 295 3.3 64 BULK-50d7b867
18189 Bulk Product 39d01f56 Home & Garden $416.60 394 3.9 97 BULK-4c708ba4
18190 Bulk Product 181a2054 Clothing $40.87 285 0.0 16 BULK-1da2a362
18191 Bulk Product 5157e80a Home & Garden $1,006.13 307 0.4 99 BULK-24c359ec
18192 Bulk Product 49fa911d Clothing $618.34 57 2.8 79 BULK-de514668
18193 Bulk Product cae472b6 Toys & Games $239.60 187 0.4 32 BULK-84c27643
18194 Bulk Product b11715bc Books $436.40 159 4.8 94 BULK-bdf503d8
18195 Bulk Product a4140a05 Toys & Games $718.73 40 0.1 80 BULK-a4f22490
18196 Bulk Product 513a444c Toys & Games $941.89 212 2.9 59 BULK-811dad47
18197 Bulk Product d6a3f69c Home & Garden $228.07 63 0.8 11 BULK-e8d60e83
18198 Bulk Product d25d5d65 Toys & Games $699.82 400 1.1 99 BULK-726d4173
18199 Bulk Product d019530d Sports & Outdoors $260.51 395 3.4 84 BULK-4db41590
18200 Bulk Product 7249ab3d Sports & Outdoors $490.87 171 4.1 46 BULK-e1e72c91
18201 Bulk Product 83032c2e Home & Garden $172.85 134 4.2 68 BULK-7221a9de
18202 Bulk Product 180fdb3f Toys & Games $841.92 226 4.9 75 BULK-bbd309ee
18203 Bulk Product b2e01d1b Books $597.86 455 0.7 88 BULK-cd402a03
18204 Bulk Product a2792299 Clothing $41.35 162 1.7 24 BULK-b211c5a1
18205 Bulk Product bd99e52a Electronics $43.61 261 3.7 91 BULK-70d731bd
18206 Bulk Product c1c5f854 Electronics $542.57 169 4.8 38 BULK-a861d0d5
18207 Bulk Product 639f5f2d Sports & Outdoors $655.90 332 2.6 1 BULK-41b3cbcc
18208 Bulk Product eb5d97a5 Sports & Outdoors $851.40 220 0.1 99 BULK-bc2deccc
18209 Bulk Product 87ed7ce8 Clothing $765.48 135 2.6 15 BULK-9d79bbcf
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