Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

14 ms

Page Size

50

Current Page

166 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 166 Results Showing 8251 - 8300 of 24441

ID Name Category Price Stock Rating Reviews SKU
8810 Bulk Product dcaa9a00 Books $42.31 378 5.0 62 BULK-99a8df9d
8811 Bulk Product a913d5f6 Sports & Outdoors $653.61 438 0.2 86 BULK-d61f6f85
8812 Bulk Product 3c7283c4 Home & Garden $256.90 390 2.6 26 BULK-66e35fff
8813 Bulk Product 971a3e65 Sports & Outdoors $985.85 421 0.7 55 BULK-0e824783
8814 Bulk Product 1e19505f Toys & Games $38.76 138 3.6 46 BULK-913f7996
8815 Bulk Product 918d1e5a Sports & Outdoors $305.09 328 0.6 61 BULK-12f79e2b
8816 Bulk Product c65a982f Electronics $225.36 336 4.4 19 BULK-63c4ccf8
8817 Bulk Product fb55ad6f Electronics $564.17 187 2.7 72 BULK-8b3758a5
8818 Bulk Product c1ed7018 Electronics $616.18 389 3.5 71 BULK-f10a686e
8819 Bulk Product a0d1e702 Clothing $263.60 188 3.6 41 BULK-e90677f8
8820 Bulk Product b7178f34 Home & Garden $216.78 475 1.8 81 BULK-7392384d
8821 Bulk Product 39d18193 Home & Garden $988.63 72 4.9 65 BULK-10383c29
8822 Bulk Product a9c42406 Toys & Games $626.18 141 3.4 86 BULK-5c9e8a30
8823 Bulk Product 9d53b951 Clothing $42.96 112 1.9 58 BULK-9cf57a66
8824 Bulk Product 810df834 Electronics $549.65 87 4.7 50 BULK-cc83387f
8825 Bulk Product 728d5d05 Home & Garden $802.56 399 1.8 32 BULK-f6684b86
8826 Bulk Product 7493ceca Sports & Outdoors $404.43 298 4.2 5 BULK-86a91477
8827 Bulk Product 91803117 Electronics $263.97 153 3.3 48 BULK-4c251b38
8828 Bulk Product e9b5c5a2 Electronics $284.68 48 3.3 68 BULK-471fbd78
8829 Bulk Product e8a206ba Clothing $682.69 374 0.7 5 BULK-faf03308
8830 Bulk Product 2f1d2634 Clothing $376.09 462 0.6 0 BULK-7d69fe60
8831 Bulk Product ee5240d0 Electronics $933.47 272 3.4 94 BULK-3b10b8b4
8832 Bulk Product 8a7e994d Home & Garden $731.25 42 1.2 17 BULK-108f264e
8833 Bulk Product fdad0be9 Clothing $845.51 14 0.7 54 BULK-60260a10
8834 Bulk Product 178f76fb Sports & Outdoors $573.25 465 0.6 25 BULK-7b7367a0
8835 Bulk Product ef56811d Sports & Outdoors $791.37 92 1.6 32 BULK-70223a03
8836 Bulk Product 944dabf1 Books $952.91 267 4.1 96 BULK-3ff3d2b2
8837 Bulk Product 3637f6ff Electronics $809.23 494 0.5 38 BULK-43d59097
8838 Bulk Product 2ce9c197 Clothing $455.46 162 2.0 61 BULK-e9c79f6a
8839 Bulk Product c8e46c9f Home & Garden $447.50 218 0.0 16 BULK-dec66c2e
8840 Bulk Product c538789f Books $664.49 62 3.7 72 BULK-e7a667a1
8841 Bulk Product d1993650 Clothing $996.27 319 4.4 31 BULK-e151bedb
8842 Bulk Product 6a9beb47 Electronics $489.19 175 3.6 83 BULK-f0acc6be
8843 Bulk Product f56a8ee7 Home & Garden $472.87 363 3.3 60 BULK-aef913bc
8844 Bulk Product e5576c59 Clothing $853.84 480 3.3 35 BULK-d409ae0b
8845 Bulk Product 1e2f1414 Home & Garden $421.45 112 3.2 51 BULK-6d1766b9
8846 Bulk Product 42e17a9e Sports & Outdoors $485.19 141 2.1 71 BULK-8037666d
8847 Bulk Product ae60c4a6 Sports & Outdoors $263.31 330 3.2 50 BULK-ce62e83d
8848 Bulk Product 890d9a39 Toys & Games $885.51 1 2.7 89 BULK-09be8d46
8849 Bulk Product 39035d5b Books $243.39 467 2.3 36 BULK-f57654fd
8850 Bulk Product ce6750e7 Home & Garden $403.38 242 1.2 46 BULK-0f94ba24
8851 Bulk Product 2eaa49b6 Toys & Games $443.69 433 5.0 57 BULK-2ba4ac85
8852 Bulk Product fa84977d Electronics $791.65 268 1.7 75 BULK-a32c433e
8853 Bulk Product 8d88f405 Sports & Outdoors $338.40 33 2.6 45 BULK-d9624b3c
8854 Bulk Product 798eb8ca Clothing $355.60 371 2.6 39 BULK-4500553d
8855 Bulk Product b6a42e41 Clothing $696.28 161 1.2 25 BULK-3449d459
8856 Bulk Product b9338b6b Clothing $448.77 189 0.8 2 BULK-27a22201
8857 Bulk Product 97e98e6b Electronics $928.53 218 4.7 41 BULK-3aab73ec
8858 Bulk Product 65140462 Clothing $960.85 403 4.4 95 BULK-2b873ca1
8859 Bulk Product 4e828847 Books $22.33 49 0.7 10 BULK-f172ba9a
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