Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

12 ms

Page Size

50

Current Page

245 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 245 Results Showing 12201 - 12250 of 24441

ID Name Category Price Stock Rating Reviews SKU
12760 Bulk Product cddb7f28 Sports & Outdoors $971.17 210 3.1 36 BULK-b0b37dec
12761 Bulk Product 2857e3d3 Sports & Outdoors $817.26 148 1.6 73 BULK-865033ed
12762 Bulk Product 2896ffc0 Toys & Games $536.87 83 4.2 33 BULK-87ed7052
12763 Bulk Product 487b0a2e Toys & Games $235.31 390 0.7 11 BULK-bb33be5e
12764 Bulk Product 8670c6a1 Books $781.94 380 3.0 73 BULK-c2450553
12765 Bulk Product f3ecbb78 Sports & Outdoors $717.88 72 1.3 11 BULK-e43cc7be
12766 Bulk Product 5b547138 Clothing $590.77 310 2.8 0 BULK-83d34836
12767 Bulk Product 5bd1b2e8 Books $142.86 167 1.2 78 BULK-bd61b478
12768 Bulk Product 560685c5 Toys & Games $329.31 478 0.7 98 BULK-a4ca1834
12769 Bulk Product 71f43ebd Toys & Games $210.75 489 3.7 16 BULK-76819326
12770 Bulk Product 66a7d3c7 Clothing $497.07 214 3.4 2 BULK-d90840ab
12771 Bulk Product b155f206 Clothing $342.52 214 1.1 57 BULK-59ae97e4
12772 Bulk Product e9fc3a2a Toys & Games $468.47 74 2.4 56 BULK-9285e52a
12773 Bulk Product 457ca25c Clothing $332.80 370 0.3 38 BULK-6ae1d323
12774 Bulk Product c63767c1 Home & Garden $224.39 395 4.0 74 BULK-c0a1c2f6
12775 Bulk Product 6571aba7 Electronics $155.89 418 4.9 19 BULK-4bf00e3a
12776 Bulk Product 9f5ff354 Toys & Games $107.70 449 3.5 87 BULK-2f0a79b6
12777 Bulk Product 04021911 Clothing $748.06 120 2.7 62 BULK-c5b276bd
12778 Bulk Product f773c3e0 Electronics $778.51 98 1.1 2 BULK-c8a85ea3
12779 Bulk Product e5326822 Sports & Outdoors $985.68 242 4.9 54 BULK-cb78cf25
12780 Bulk Product a0dfff55 Clothing $443.69 75 2.0 88 BULK-9990a6d6
12781 Bulk Product 2642de3d Sports & Outdoors $916.42 275 1.2 79 BULK-36a742a2
12782 Bulk Product 4f374b4e Home & Garden $25.99 390 1.1 50 BULK-82962048
12783 Bulk Product 030689c8 Home & Garden $445.59 277 2.2 21 BULK-38e28c11
12784 Bulk Product 2a03567f Clothing $56.42 144 1.8 69 BULK-16a5abbb
12785 Bulk Product 50afe8a5 Sports & Outdoors $158.98 163 1.7 59 BULK-96aeb7f7
12786 Bulk Product 38c57ca4 Books $761.69 408 0.1 52 BULK-a9def626
12787 Bulk Product f4099c8a Home & Garden $76.68 404 4.8 0 BULK-cd5fd778
12788 Bulk Product cf1da32e Books $83.43 98 0.6 81 BULK-562569d8
12789 Bulk Product 290dfbfb Home & Garden $127.77 174 1.6 51 BULK-95b7f13c
12790 Bulk Product 63628a17 Clothing $220.39 392 1.6 20 BULK-52ea2983
12791 Bulk Product 0139305b Home & Garden $962.70 276 3.2 14 BULK-83488ead
12792 Bulk Product 9d5fd9fe Toys & Games $940.56 21 4.2 52 BULK-67f8df62
12793 Bulk Product 80473618 Home & Garden $535.12 363 2.7 24 BULK-6eabda68
12794 Bulk Product 20abff88 Books $779.55 494 1.3 70 BULK-8bb06d18
12795 Bulk Product c4b098c0 Sports & Outdoors $621.65 286 4.2 73 BULK-320ab479
12796 Bulk Product a1390e14 Home & Garden $511.90 94 0.0 67 BULK-62dc424e
12797 Bulk Product af009e89 Books $151.29 132 0.5 91 BULK-becf5988
12798 Bulk Product 057415ba Sports & Outdoors $951.18 382 1.7 86 BULK-de7918e1
12799 Bulk Product fdae9a00 Sports & Outdoors $324.08 323 2.5 16 BULK-8e0bca4f
12800 Bulk Product 5d913111 Sports & Outdoors $579.91 393 0.8 60 BULK-8a0d99c9
12801 Bulk Product 1d40900e Home & Garden $465.03 25 0.7 99 BULK-b747149c
12802 Bulk Product 93c4ae86 Books $661.97 267 3.2 56 BULK-44f5ea46
12803 Bulk Product 246e6d70 Clothing $802.86 71 1.9 56 BULK-3ea61340
12804 Bulk Product b7d7806a Sports & Outdoors $70.91 363 4.5 90 BULK-eb544ade
12805 Bulk Product fabdacd6 Clothing $893.26 222 1.9 14 BULK-55762d83
12806 Bulk Product 05152daa Electronics $328.57 37 0.4 35 BULK-bdeedc2c
12807 Bulk Product 16946a0d Toys & Games $997.02 169 2.0 0 BULK-9f81298a
12808 Bulk Product a3e750cd Sports & Outdoors $498.04 486 2.3 0 BULK-bc0efdbc
12809 Bulk Product c4d62419 Electronics $728.43 415 1.0 3 BULK-770539b4
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