Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

43 ms

Page Size

50

Current Page

307 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 307 Results Showing 15301 - 15350 of 24441

ID Name Category Price Stock Rating Reviews SKU
15860 Bulk Product d1b4bbd8 Home & Garden $572.38 2 0.8 44 BULK-0b4c370a
15861 Bulk Product 930e768c Books $142.19 22 0.8 94 BULK-59f9b2cd
15862 Bulk Product 63cc3cfa Home & Garden $533.12 406 0.1 40 BULK-f46327d9
15863 Bulk Product 90c15a2b Books $318.25 275 1.3 2 BULK-5a78df9b
15864 Bulk Product 3f234a8a Electronics $55.03 161 1.2 85 BULK-fa332134
15865 Bulk Product 98dc286e Toys & Games $410.48 278 5.0 76 BULK-2da84070
15866 Bulk Product d76a5c63 Electronics $905.83 397 2.5 4 BULK-3c5f68ef
15867 Bulk Product 7d7c8937 Sports & Outdoors $276.52 473 2.3 1 BULK-11627582
15868 Bulk Product 0815961f Electronics $823.52 280 4.8 14 BULK-d423df7c
15869 Bulk Product 85fceee8 Home & Garden $380.04 389 4.5 80 BULK-ffb0a082
15870 Bulk Product f2e39606 Clothing $466.64 395 0.5 4 BULK-ac034672
15871 Bulk Product ad5d3888 Electronics $382.49 182 4.5 23 BULK-bf2c20fd
15872 Bulk Product c9268f5d Toys & Games $671.24 470 2.6 79 BULK-648a3f60
15873 Bulk Product 802a9b33 Home & Garden $513.82 271 2.5 97 BULK-f81c3195
15874 Bulk Product 7252cf8e Clothing $68.61 450 3.4 69 BULK-30756bd3
15875 Bulk Product 3162cf75 Books $482.10 37 4.3 68 BULK-b13ddd21
15876 Bulk Product 3291f0c4 Clothing $131.01 237 0.7 45 BULK-a0d2103a
15877 Bulk Product a2fa0172 Sports & Outdoors $226.59 258 0.7 77 BULK-4ed89358
15878 Bulk Product e19a5a53 Electronics $953.01 70 2.5 78 BULK-18576aa0
15879 Bulk Product 55e8ea8d Electronics $305.10 307 0.6 9 BULK-d96dd0e8
15880 Bulk Product c627b382 Sports & Outdoors $316.71 291 3.5 57 BULK-ceb5cf4b
15881 Bulk Product 758ee81f Home & Garden $935.27 45 2.2 77 BULK-1fe1beaf
15882 Bulk Product 62aaa215 Electronics $658.21 107 2.3 1 BULK-74124b22
15883 Bulk Product 5ac7e656 Clothing $648.27 168 3.5 30 BULK-bde60bd4
15884 Bulk Product d424e0f8 Clothing $162.17 199 0.3 33 BULK-2c6fbaf5
15885 Bulk Product 5717721d Home & Garden $477.16 16 1.9 8 BULK-ba637001
15886 Bulk Product 269d62ec Clothing $642.44 499 1.3 53 BULK-394a753e
15887 Bulk Product 13cbe0a5 Home & Garden $830.19 421 4.1 76 BULK-2e8d58de
15888 Bulk Product efd4987c Sports & Outdoors $649.52 62 3.0 79 BULK-e55f57aa
15889 Bulk Product 848fdb4e Sports & Outdoors $299.52 449 3.8 61 BULK-ffec493f
15890 Bulk Product bf798976 Sports & Outdoors $952.59 351 4.4 81 BULK-c86100ef
15891 Bulk Product 0bd269ff Clothing $691.26 181 4.4 81 BULK-eb0fd7d9
15892 Bulk Product 885be68e Clothing $233.58 189 3.7 39 BULK-e30d8a7b
15893 Bulk Product a08ca1c5 Electronics $830.42 41 2.6 3 BULK-0527e2bc
15894 Bulk Product d6ea61c9 Sports & Outdoors $280.72 409 4.1 15 BULK-bfda9422
15895 Bulk Product 79dd1f8c Sports & Outdoors $738.74 168 3.3 95 BULK-c072af3e
15896 Bulk Product 1ed3d3f5 Sports & Outdoors $513.37 451 4.1 1 BULK-0a56f76f
15897 Bulk Product 2595d3e1 Toys & Games $208.23 324 0.0 44 BULK-c3b3bfa4
15898 Bulk Product e60572b2 Toys & Games $989.46 281 2.3 99 BULK-ca663235
15899 Bulk Product 8a312baf Home & Garden $873.69 335 2.6 49 BULK-8886b5c5
15900 Bulk Product 529f9ea4 Home & Garden $884.84 40 3.9 53 BULK-64473645
15901 Bulk Product ebd4ebf7 Toys & Games $275.67 354 2.3 95 BULK-9963bec5
15902 Bulk Product 768c77de Electronics $661.33 83 0.5 44 BULK-cc1312a5
15903 Bulk Product b54db0cd Home & Garden $317.93 10 2.1 82 BULK-0a5fa1ed
15904 Bulk Product 08c4ce88 Clothing $101.90 297 3.4 86 BULK-dc7c49fa
15905 Bulk Product 0e5e71a2 Clothing $305.81 490 2.3 1 BULK-59c6e875
15906 Bulk Product b1621c8c Books $11.58 112 0.5 86 BULK-602a9f65
15907 Bulk Product 4211182f Electronics $877.34 413 2.8 5 BULK-ec6e68bb
15908 Bulk Product db500a5b Toys & Games $579.27 85 1.7 3 BULK-9ec322a3
15909 Bulk Product e4754c8d Books $208.58 192 0.9 66 BULK-7311e551
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