Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

20 ms

Page Size

50

Current Page

190 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 190 Results Showing 9451 - 9500 of 24441

ID Name Category Price Stock Rating Reviews SKU
10010 Bulk Product 6c81725b Clothing $570.37 19 3.0 77 BULK-c98149f0
10011 Bulk Product 8d89c352 Toys & Games $864.78 246 1.2 41 BULK-e7384aeb
10012 Bulk Product 61e1e7ea Clothing $74.02 43 2.2 86 BULK-ba74023a
10013 Bulk Product 269aabe9 Sports & Outdoors $220.93 214 1.9 3 BULK-a4dc98a4
10014 Bulk Product 651cc72e Home & Garden $742.20 33 3.9 98 BULK-e4284f1b
10015 Bulk Product a9fe443d Sports & Outdoors $190.73 297 2.7 92 BULK-19d242dc
10016 Bulk Product d1bb35b1 Clothing $144.39 81 1.0 7 BULK-91731ec8
10017 Bulk Product 447bc894 Sports & Outdoors $664.85 499 3.7 52 BULK-3364dba1
10018 Bulk Product 1a2abf56 Electronics $410.51 403 4.0 29 BULK-ddeb8773
10019 Bulk Product 0c67b0e5 Sports & Outdoors $967.67 330 5.0 22 BULK-f2028bdc
10020 Bulk Product 6b1e6f81 Books $405.41 409 4.4 10 BULK-7a5df586
10021 Bulk Product af32b2ca Clothing $290.13 449 2.5 99 BULK-32fc5475
10022 Bulk Product 104ec175 Electronics $387.83 173 1.6 0 BULK-82667380
10023 Bulk Product a402da52 Clothing $67.53 449 3.9 64 BULK-5294b4fd
10024 Bulk Product ae77d298 Sports & Outdoors $314.65 354 4.1 44 BULK-11d67b1b
10025 Bulk Product 37bdcf77 Clothing $884.73 8 4.4 89 BULK-7f2a65f0
10026 Bulk Product 6fd0abbb Sports & Outdoors $826.53 408 4.8 93 BULK-4e2ecb05
10027 Bulk Product 49ee37bf Home & Garden $502.23 382 0.0 10 BULK-4a37dbe6
10028 Bulk Product 83895b9e Electronics $267.11 155 2.4 99 BULK-a3a896eb
10029 Bulk Product 56651955 Toys & Games $219.98 148 0.8 59 BULK-947749f6
10030 Bulk Product 230f54ec Home & Garden $433.42 133 1.8 43 BULK-fbb6a73f
10031 Bulk Product 1dffa62a Toys & Games $426.46 201 2.6 54 BULK-252c4b0f
10032 Bulk Product 1dccce97 Books $393.48 219 2.5 1 BULK-724619cf
10033 Bulk Product 6e693aa9 Sports & Outdoors $677.57 21 3.2 91 BULK-70d65faf
10034 Bulk Product 798f0dba Books $963.42 120 4.1 38 BULK-eb6caf7a
10035 Bulk Product 9e78dd51 Sports & Outdoors $735.85 57 0.3 6 BULK-61cbf29b
10036 Bulk Product f115aa8b Sports & Outdoors $990.20 446 1.5 97 BULK-2e5dc9a5
10037 Bulk Product 3f4510cf Electronics $240.86 490 2.1 14 BULK-72ffda81
10038 Bulk Product e2a9dbbc Toys & Games $763.45 36 2.3 39 BULK-69f7195f
10039 Bulk Product d8c97cf5 Electronics $276.16 160 0.6 44 BULK-bf21acb8
10040 Bulk Product 18da4b20 Home & Garden $261.27 138 1.9 73 BULK-27678f67
10041 Bulk Product 0f25ba0e Electronics $595.82 33 2.0 2 BULK-e82a2ecf
10042 Bulk Product 4b0b15f3 Clothing $445.90 297 2.0 81 BULK-ee164375
10043 Bulk Product 41730bbf Books $529.23 7 0.4 27 BULK-03e90d24
10044 Bulk Product 3ef39d20 Clothing $295.96 180 2.6 22 BULK-3a87ccdb
10045 Bulk Product 5758905c Electronics $343.03 360 1.2 19 BULK-38a3e1a4
10046 Bulk Product 551bddb7 Electronics $277.67 297 3.6 76 BULK-78dde8f7
10047 Bulk Product fd8b37de Home & Garden $278.79 316 0.7 56 BULK-00e54a4b
10048 Bulk Product 13f98da8 Home & Garden $978.23 105 4.6 31 BULK-441a37b6
10049 Bulk Product 256b046d Clothing $723.75 13 4.4 89 BULK-02b42655
10050 Bulk Product dc60633f Sports & Outdoors $512.23 335 4.7 28 BULK-eb509297
10051 Bulk Product 8390c593 Toys & Games $842.98 374 3.4 60 BULK-1bbc8a19
10052 Bulk Product 661c81b3 Books $86.13 176 4.7 71 BULK-8fe4575e
10053 Bulk Product a28e1af8 Toys & Games $571.01 172 0.4 13 BULK-eb7ad5df
10054 Bulk Product 0810a311 Electronics $546.74 248 1.8 45 BULK-c1f6ddd6
10055 Bulk Product 6d82f425 Home & Garden $136.62 346 0.2 57 BULK-a2c807de
10056 Bulk Product b9ea7e7d Clothing $826.11 370 1.3 16 BULK-2a063b18
10057 Bulk Product b0ebd54f Clothing $802.61 79 0.5 59 BULK-adaae8e8
10058 Bulk Product 0c0f01fc Toys & Games $121.97 3 4.8 47 BULK-c4f66807
10059 Bulk Product a006b7a5 Sports & Outdoors $485.92 69 4.5 4 BULK-ad068491
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