Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

11 ms

Page Size

50

Current Page

152 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 152 Results Showing 7551 - 7600 of 24441

ID Name Category Price Stock Rating Reviews SKU
8110 Bulk Product 84f345fe Electronics $192.24 225 4.8 6 BULK-b3e57705
8111 Bulk Product b278f88c Clothing $573.71 414 1.8 37 BULK-e555cc7f
8112 Bulk Product 1ea877b4 Sports & Outdoors $814.51 23 2.8 9 BULK-e360b601
8113 Bulk Product 42d4fa08 Clothing $754.37 348 4.5 51 BULK-56357d6d
8114 Bulk Product 64feaf6d Toys & Games $787.22 132 2.7 66 BULK-3a7b96d5
8115 Bulk Product a18f30f6 Sports & Outdoors $207.42 452 4.1 48 BULK-8e7cefa0
8116 Bulk Product f2286837 Toys & Games $320.47 79 2.8 19 BULK-ba807b40
8117 Bulk Product 9b280fd2 Home & Garden $557.82 455 2.7 28 BULK-d4ffee0b
8118 Bulk Product 8dad3ee1 Home & Garden $772.53 334 2.9 62 BULK-81a89a0f
8119 Bulk Product 0449e06c Books $280.12 154 3.7 79 BULK-bdfe21f2
8120 Bulk Product cf52dbf3 Toys & Games $265.08 321 1.6 67 BULK-039de548
8121 Bulk Product f60387a2 Sports & Outdoors $170.61 99 0.4 7 BULK-dce7ff57
8122 Bulk Product 0f44aac4 Toys & Games $516.69 305 2.5 57 BULK-2eea087d
8123 Bulk Product 7cede6d3 Electronics $939.94 112 2.5 72 BULK-02563ee6
8124 Bulk Product e7870026 Toys & Games $763.20 183 4.5 30 BULK-92b5c7d5
8125 Bulk Product 9f5b7cf5 Sports & Outdoors $351.06 252 1.5 53 BULK-8d09a3aa
8126 Bulk Product c4d2a5fb Home & Garden $547.76 78 3.2 30 BULK-a59f37af
8127 Bulk Product ba5b986a Clothing $805.27 362 1.3 4 BULK-76a497f0
8128 Bulk Product f2d233ce Sports & Outdoors $1,000.02 176 4.2 46 BULK-aeae45c1
8129 Bulk Product 16eb5960 Electronics $127.26 305 1.7 97 BULK-e1115384
8130 Bulk Product 56380e3d Home & Garden $208.56 199 0.8 31 BULK-0a603da2
8131 Bulk Product 98ca9a24 Toys & Games $383.44 90 4.0 19 BULK-edfabbdd
8132 Bulk Product 98a92313 Toys & Games $1,001.34 237 2.5 4 BULK-a1ad1f6c
8133 Bulk Product 6b8091f3 Home & Garden $810.69 113 2.3 14 BULK-b9ca91a7
8134 Bulk Product 7f7dec69 Electronics $74.40 99 3.8 18 BULK-d200965c
8135 Bulk Product 62416bab Clothing $233.08 311 0.5 85 BULK-7ebb9ab0
8136 Bulk Product faad0474 Clothing $492.23 202 0.9 96 BULK-292bdc2f
8137 Bulk Product 094e405c Clothing $322.31 265 1.0 2 BULK-8c0c3744
8138 Bulk Product 724ea731 Sports & Outdoors $845.40 290 4.4 36 BULK-45dce1b9
8139 Bulk Product fad006a7 Sports & Outdoors $102.61 322 0.1 70 BULK-635d668c
8140 Bulk Product 1665461a Sports & Outdoors $405.16 98 1.8 18 BULK-6b964037
8141 Bulk Product 869da72b Electronics $25.57 15 4.3 20 BULK-fd261091
8142 Bulk Product 6b2d5252 Sports & Outdoors $944.75 136 0.6 34 BULK-adee1653
8143 Bulk Product cca4f14d Electronics $985.86 222 2.3 92 BULK-097617b9
8144 Bulk Product 114e1a02 Sports & Outdoors $586.83 247 1.0 11 BULK-29d02eec
8145 Bulk Product d04b464c Home & Garden $381.74 91 0.3 91 BULK-14812afa
8146 Bulk Product ece29664 Sports & Outdoors $440.55 428 0.6 73 BULK-31950183
8147 Bulk Product 12898986 Toys & Games $79.16 267 2.0 28 BULK-3e049239
8148 Bulk Product 8538751e Clothing $488.35 48 1.3 52 BULK-8cd441df
8149 Bulk Product 9bb0048c Clothing $931.35 37 4.3 16 BULK-8738d772
8150 Bulk Product bb2c508f Electronics $918.58 383 2.3 23 BULK-309bec5d
8151 Bulk Product 14a8c159 Books $49.69 112 1.4 81 BULK-4517c1de
8152 Bulk Product 7f66364c Clothing $570.07 250 4.4 62 BULK-61681e51
8153 Bulk Product 4eca5033 Books $51.24 73 4.4 36 BULK-7c97a9da
8154 Bulk Product c790b071 Toys & Games $457.69 357 4.1 71 BULK-524eef5b
8155 Bulk Product 98626716 Electronics $282.84 12 1.1 83 BULK-3d219960
8156 Bulk Product 44153b1a Home & Garden $345.98 164 1.7 53 BULK-ffe4a208
8157 Bulk Product 7751d158 Toys & Games $122.06 442 0.5 42 BULK-18e64bf3
8158 Bulk Product e14a01b9 Clothing $706.89 137 4.5 16 BULK-4fce05ec
8159 Bulk Product d424efdc Clothing $219.68 241 3.7 4 BULK-5f646a76
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