Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

37 ms

Page Size

50

Current Page

425 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 425 Results Showing 21201 - 21250 of 24441

ID Name Category Price Stock Rating Reviews SKU
21760 Bulk Product e05dc45a Toys & Games $880.14 174 1.6 36 BULK-2b19aabd
21761 Bulk Product be49308f Toys & Games $854.42 215 1.8 63 BULK-58fb61ff
21762 Bulk Product 751de029 Clothing $335.63 394 3.4 55 BULK-72053a99
21763 Bulk Product 841ed72e Sports & Outdoors $362.85 304 4.9 36 BULK-2cfac022
21764 Bulk Product f17e8aa2 Clothing $867.92 478 1.1 63 BULK-09dcef9d
21765 Bulk Product 29709a27 Books $389.41 440 3.8 26 BULK-9defc8d7
21766 Bulk Product eb27997a Books $343.59 247 4.4 46 BULK-01e4071c
21767 Bulk Product 5cf8652a Toys & Games $232.82 450 4.6 63 BULK-37a8b507
21768 Bulk Product 30966940 Toys & Games $182.64 205 0.5 7 BULK-d965b879
21769 Bulk Product c56feb5e Clothing $81.01 194 2.8 48 BULK-dfac1cf9
21770 Bulk Product 3c1fd89d Sports & Outdoors $82.64 156 1.6 44 BULK-168d8fbb
21771 Bulk Product a29260ed Electronics $943.09 127 3.5 30 BULK-3d50802f
21772 Bulk Product 6d315c41 Sports & Outdoors $186.63 86 4.3 76 BULK-32ec47cc
21773 Bulk Product 7cd5c458 Home & Garden $751.35 324 1.9 40 BULK-f731f14b
21774 Bulk Product 3524bc96 Home & Garden $67.98 314 2.1 71 BULK-113e5730
21775 Bulk Product e7c6161a Electronics $333.91 406 2.5 29 BULK-13fd537e
21776 Bulk Product 122152d5 Toys & Games $342.09 465 5.0 27 BULK-6f2a18fa
21777 Bulk Product 154c91f1 Toys & Games $223.89 343 0.3 61 BULK-a3812e99
21778 Bulk Product 28d1778b Books $966.36 175 1.3 80 BULK-399bd2cc
21779 Bulk Product 9fd6ae95 Sports & Outdoors $940.15 342 4.8 13 BULK-318d5f31
21780 Bulk Product 6755e89a Clothing $845.51 472 3.6 67 BULK-77207b0e
21781 Bulk Product 48ac1b83 Sports & Outdoors $475.14 97 3.4 24 BULK-fa3c4e8b
21782 Bulk Product 90070325 Books $815.91 359 4.4 44 BULK-ee6b3753
21783 Bulk Product 4eddf898 Toys & Games $199.06 231 4.1 51 BULK-3cdc1d27
21784 Bulk Product 99e2ab5f Home & Garden $552.35 317 2.3 4 BULK-88b7c38a
21785 Bulk Product d61d257a Clothing $519.30 343 4.7 82 BULK-749d7ed8
21786 Bulk Product f661a01c Clothing $453.20 478 1.8 83 BULK-42d41f71
21787 Bulk Product 0b650a9e Electronics $451.52 37 2.8 47 BULK-0e0c761a
21788 Bulk Product 75ba10fe Clothing $573.52 377 1.1 2 BULK-d428eabc
21789 Bulk Product ee18e0ff Electronics $280.49 406 2.0 74 BULK-81398f4e
21790 Bulk Product c32661e6 Clothing $354.85 381 0.7 28 BULK-19a51e90
21791 Bulk Product 957f070a Toys & Games $60.11 387 4.4 27 BULK-29cc28b6
21792 Bulk Product 95565fc8 Books $856.73 351 3.3 35 BULK-7d5986b5
21793 Bulk Product d8412f2e Clothing $288.13 451 1.2 32 BULK-e660b08e
21794 Bulk Product 322e80b7 Toys & Games $278.91 355 3.7 91 BULK-64bb6acd
21795 Bulk Product e7b4ddef Electronics $586.72 104 1.3 89 BULK-7f59b2fd
21796 Bulk Product 30b79f03 Electronics $911.33 104 1.3 95 BULK-b637532f
21797 Bulk Product 6489724e Books $308.82 448 1.7 19 BULK-98d97d38
21798 Bulk Product fd180a65 Sports & Outdoors $467.55 155 4.9 24 BULK-5ba8e3cc
21799 Bulk Product bebcea9b Sports & Outdoors $356.07 50 1.7 14 BULK-01eb421e
21800 Bulk Product ecd3b7ce Home & Garden $19.39 216 3.5 38 BULK-3548536b
21801 Bulk Product e63e3656 Clothing $776.14 12 0.2 79 BULK-b65495e8
21802 Bulk Product f951a0df Electronics $111.79 270 4.7 62 BULK-f589a716
21803 Bulk Product 042d79aa Clothing $344.41 109 4.6 74 BULK-e24de9ce
21804 Bulk Product 58315800 Sports & Outdoors $628.21 484 4.9 5 BULK-92720c0f
21805 Bulk Product 7f90f8c0 Electronics $899.98 432 3.9 77 BULK-69c85b40
21806 Bulk Product e63622cf Home & Garden $280.00 257 2.0 92 BULK-b90c8944
21807 Bulk Product a5d5f2f3 Toys & Games $53.41 85 1.5 6 BULK-26eaf396
21808 Bulk Product 61ab36a0 Clothing $79.66 496 2.4 46 BULK-2cc7e1ea
21809 Bulk Product aec63d83 Toys & Games $142.71 477 0.8 46 BULK-79f92080
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