Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

96 ms

Page Size

50

Current Page

365 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 365 Results Showing 18201 - 18250 of 24441

ID Name Category Price Stock Rating Reviews SKU
18760 Bulk Product 347837c4 Electronics $494.28 379 4.2 81 BULK-79445486
18761 Bulk Product 2e047ff7 Books $187.26 322 1.2 67 BULK-48210d31
18762 Bulk Product bd256936 Sports & Outdoors $63.73 15 4.5 21 BULK-30265aed
18763 Bulk Product 0e7338e5 Toys & Games $878.19 264 3.6 70 BULK-796873b8
18764 Bulk Product 2f68bc1b Electronics $793.33 114 2.4 80 BULK-c248d6c7
18765 Bulk Product 168fd58f Clothing $861.12 355 4.6 94 BULK-b41688a3
18766 Bulk Product 320c5517 Toys & Games $396.91 304 4.7 34 BULK-31e86660
18767 Bulk Product 5452fbb5 Home & Garden $458.43 353 3.0 58 BULK-2e1db2de
18768 Bulk Product 15bb75b3 Sports & Outdoors $251.83 196 1.5 78 BULK-3eab7969
18769 Bulk Product a835aa04 Books $791.56 230 2.4 18 BULK-9c68b11e
18770 Bulk Product 68715ee9 Clothing $875.26 296 2.0 59 BULK-5b4a8ddd
18771 Bulk Product 39d8a2ea Electronics $924.98 20 1.6 19 BULK-cd8e4541
18772 Bulk Product c83f1d6f Clothing $599.73 193 2.0 10 BULK-d9c4f40a
18773 Bulk Product 19455f6f Home & Garden $312.14 188 2.5 88 BULK-abbf9161
18774 Bulk Product 8cd5b198 Books $527.87 472 1.9 93 BULK-b8019145
18775 Bulk Product 3d4f6175 Clothing $884.55 492 4.7 29 BULK-613768a0
18776 Bulk Product e478b5ba Toys & Games $531.17 251 0.0 65 BULK-faf3d417
18777 Bulk Product b973f241 Clothing $314.24 72 4.7 21 BULK-fb7a04e9
18778 Bulk Product e283530a Clothing $854.56 230 0.6 63 BULK-2fade878
18779 Bulk Product dfba99a8 Sports & Outdoors $788.31 16 4.2 62 BULK-717f6c9f
18780 Bulk Product c2f652a1 Electronics $165.69 288 3.4 20 BULK-0386df4d
18781 Bulk Product b4328ae0 Toys & Games $175.70 204 1.6 24 BULK-6dad3ce4
18782 Bulk Product 196825da Electronics $309.60 262 0.7 18 BULK-be886330
18783 Bulk Product 5f2b9e51 Clothing $646.11 427 1.4 92 BULK-21dcac38
18784 Bulk Product 711a36df Sports & Outdoors $935.73 46 0.3 56 BULK-5d1f0d23
18785 Bulk Product 595ea47f Toys & Games $562.37 445 3.1 31 BULK-7ee042eb
18786 Bulk Product 32f2b99b Toys & Games $991.15 352 1.4 19 BULK-d3ac0ad6
18787 Bulk Product 2059aace Clothing $366.56 417 1.0 91 BULK-c87e3b78
18788 Bulk Product 7ff3329f Electronics $57.59 94 4.3 78 BULK-cf8d6eb9
18789 Bulk Product 86f86afb Home & Garden $786.43 338 0.9 17 BULK-9ddc5dfa
18790 Bulk Product b1d0f5ea Home & Garden $446.42 310 4.7 83 BULK-3a9b55aa
18791 Bulk Product 269598a1 Toys & Games $254.76 148 2.3 20 BULK-f05db03f
18792 Bulk Product 970fab09 Electronics $279.22 377 0.1 74 BULK-1b9eec4b
18793 Bulk Product 7643b6af Toys & Games $672.69 209 1.5 98 BULK-3b2c2969
18794 Bulk Product 0da54b0c Clothing $725.10 11 1.7 27 BULK-aaa713c6
18795 Bulk Product 6280593e Home & Garden $156.40 207 4.3 25 BULK-2d2e8608
18796 Bulk Product ca88ec05 Toys & Games $383.91 275 1.1 1 BULK-f4af1fe2
18797 Bulk Product bf7ddaba Electronics $738.57 204 3.0 71 BULK-9606d035
18798 Bulk Product fb03aa04 Toys & Games $748.51 3 4.3 97 BULK-8f0e8f62
18799 Bulk Product 1f3b64d2 Toys & Games $821.19 306 3.7 99 BULK-1cc3b328
18800 Bulk Product bff03c28 Home & Garden $147.41 386 2.9 35 BULK-13436b55
18801 Bulk Product 0c51ed8e Clothing $928.85 384 1.3 18 BULK-8c246333
18802 Bulk Product ad20b8f3 Electronics $258.41 327 0.2 19 BULK-ac0baf1e
18803 Bulk Product 8a7048cd Sports & Outdoors $407.39 358 0.8 78 BULK-3b5b7a2d
18804 Bulk Product cc6fea46 Clothing $770.79 44 0.0 66 BULK-58b6b5e5
18805 Bulk Product 5159b8d8 Home & Garden $956.78 198 3.8 85 BULK-8cfda243
18806 Bulk Product 936343f1 Sports & Outdoors $450.37 443 4.6 93 BULK-d176ec7f
18807 Bulk Product e3c9bc60 Electronics $877.32 481 1.0 52 BULK-e6ada4ac
18808 Bulk Product 90abaa95 Home & Garden $44.27 420 2.8 63 BULK-a3b2d7ad
18809 Bulk Product 093438c1 Electronics $654.77 106 3.2 48 BULK-48e618a5
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