Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

10 ms

Page Size

25

Current Page

449 / 978

Total Records

24441

Items per page: 25 50 100 200

Page 449 Results Showing 11201 - 11225 of 24441

ID Name Category Price Stock Rating Reviews SKU
11760 Bulk Product 15285987 Sports & Outdoors $942.81 240 1.5 13 BULK-42ee143c
11761 Bulk Product 6165e007 Books $461.07 364 1.2 39 BULK-f1d18593
11762 Bulk Product 6b7c1cd1 Home & Garden $932.66 174 3.9 50 BULK-f2e83596
11763 Bulk Product ad38503b Electronics $50.73 314 1.8 5 BULK-01391dae
11764 Bulk Product b8b36171 Sports & Outdoors $487.42 79 3.6 54 BULK-a509d47d
11765 Bulk Product db03baaf Home & Garden $720.99 148 4.7 80 BULK-a6008c92
11766 Bulk Product f2ac9363 Books $517.99 485 0.9 15 BULK-7f73bcd7
11767 Bulk Product 627dd210 Electronics $474.05 225 2.9 67 BULK-69aba7e0
11768 Bulk Product 8187fb9d Sports & Outdoors $45.75 130 4.0 47 BULK-aa0fd431
11769 Bulk Product b0285793 Electronics $443.41 428 4.6 62 BULK-dc19a3bb
11770 Bulk Product 4ef243d2 Electronics $653.00 284 4.2 27 BULK-859e6945
11771 Bulk Product c70fdf0f Books $615.15 39 2.9 72 BULK-1d7ee25e
11772 Bulk Product abb7854b Clothing $527.40 26 0.5 77 BULK-f3912570
11773 Bulk Product 68f75db4 Home & Garden $686.10 212 4.9 34 BULK-161cfbf8
11774 Bulk Product 13192b2a Toys & Games $538.16 203 2.9 2 BULK-9665d396
11775 Bulk Product d2dc0d99 Electronics $125.14 285 1.2 38 BULK-fa1d7245
11776 Bulk Product a9ea71fe Electronics $830.16 122 3.2 90 BULK-428d223b
11777 Bulk Product d561b5ba Home & Garden $981.78 450 1.5 95 BULK-63551241
11778 Bulk Product f1f0c9e1 Sports & Outdoors $862.08 118 2.0 3 BULK-b3fe488e
11779 Bulk Product 41d4535d Books $623.06 108 2.3 8 BULK-7be14979
11780 Bulk Product 0999880f Electronics $348.36 416 1.3 37 BULK-2bcb64ce
11781 Bulk Product b10b9828 Books $158.26 452 3.1 8 BULK-5382b3e4
11782 Bulk Product 594d93bc Clothing $120.15 400 3.7 5 BULK-a0498384
11783 Bulk Product cfa0d165 Sports & Outdoors $905.77 163 3.6 37 BULK-a9c35b28
11784 Bulk Product c0035b1f Books $795.40 241 3.2 84 BULK-4faac094
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