Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

15 ms

Page Size

50

Current Page

305 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 305 Results Showing 15201 - 15250 of 24441

ID Name Category Price Stock Rating Reviews SKU
15760 Bulk Product ac9562c9 Toys & Games $276.68 194 3.9 12 BULK-d16b943d
15761 Bulk Product 942f9e4e Sports & Outdoors $645.08 393 2.6 29 BULK-c763e6ec
15762 Bulk Product e06cbcf1 Books $679.19 281 4.8 72 BULK-8090e393
15763 Bulk Product 7ea5a5f2 Toys & Games $416.04 375 2.0 20 BULK-80cf86c0
15764 Bulk Product d5eb5508 Electronics $566.66 25 1.4 31 BULK-9a26bbfa
15765 Bulk Product 51eb579a Home & Garden $937.16 345 1.6 12 BULK-62c83488
15766 Bulk Product f6ddb075 Sports & Outdoors $282.16 392 4.1 86 BULK-246ed610
15767 Bulk Product 95b8dc1c Books $862.33 147 1.8 3 BULK-05325756
15768 Bulk Product 931f325e Clothing $421.42 25 4.7 4 BULK-3d8ceca9
15769 Bulk Product fd80d942 Clothing $227.90 154 4.7 82 BULK-66c92b01
15770 Bulk Product 6dcd6f61 Sports & Outdoors $540.62 339 4.2 49 BULK-a0f58e77
15771 Bulk Product 4c2199d9 Toys & Games $590.77 469 0.3 49 BULK-63edcccc
15772 Bulk Product 22ff5477 Home & Garden $527.75 380 1.8 36 BULK-84000870
15773 Bulk Product f360a206 Sports & Outdoors $274.31 319 3.5 66 BULK-75cd586d
15774 Bulk Product d08aaa72 Books $504.51 99 4.6 95 BULK-10e17737
15775 Bulk Product bfd1eb43 Electronics $402.67 228 3.0 91 BULK-3577f396
15776 Bulk Product a1fb5f9e Clothing $606.59 118 1.0 9 BULK-e7f0c724
15777 Bulk Product f580c7ed Sports & Outdoors $599.49 57 4.8 26 BULK-f3c5db10
15778 Bulk Product b6125584 Home & Garden $113.60 346 4.0 81 BULK-1373c3bf
15779 Bulk Product aa0f05c6 Electronics $705.37 430 4.8 88 BULK-d8c433dc
15780 Bulk Product 89a0f9b0 Books $705.50 464 2.1 49 BULK-0bdd5ce4
15781 Bulk Product 9f6dad30 Toys & Games $281.61 277 1.1 47 BULK-8bccaecb
15782 Bulk Product b5083613 Clothing $597.90 83 4.3 66 BULK-46c3016f
15783 Bulk Product 6017901a Sports & Outdoors $45.28 319 3.0 5 BULK-b9e53e00
15784 Bulk Product 27f79338 Electronics $249.90 67 4.2 7 BULK-f809f70c
15785 Bulk Product ea31562b Sports & Outdoors $54.19 467 1.0 72 BULK-22ce19db
15786 Bulk Product 34465f59 Books $395.99 476 3.5 70 BULK-a3ec4766
15787 Bulk Product fa4c5cb2 Clothing $829.01 182 0.8 87 BULK-50375315
15788 Bulk Product e68f75d7 Electronics $753.30 10 4.5 8 BULK-f3aea6e3
15789 Bulk Product 764cb1a4 Home & Garden $686.22 87 0.3 78 BULK-f91393ca
15790 Bulk Product ca8cfc1c Home & Garden $923.54 254 1.7 81 BULK-e7cdbc8c
15791 Bulk Product ae12be23 Home & Garden $493.60 133 3.7 38 BULK-6ad44002
15792 Bulk Product 977243f7 Sports & Outdoors $796.33 81 2.1 39 BULK-fabffdbe
15793 Bulk Product 214da8d6 Books $893.02 386 4.0 94 BULK-d213ecbb
15794 Bulk Product b81dfb40 Clothing $904.45 108 0.9 33 BULK-95e0c896
15795 Bulk Product bbcb5318 Toys & Games $403.80 374 1.5 22 BULK-ff03e878
15796 Bulk Product 1d8849cf Toys & Games $217.05 329 3.6 86 BULK-12e3b551
15797 Bulk Product 305008b6 Sports & Outdoors $873.53 43 3.3 31 BULK-d754d0ce
15798 Bulk Product bda64a98 Clothing $237.62 42 2.4 29 BULK-642baee3
15799 Bulk Product 06fa61fa Sports & Outdoors $14.58 405 2.9 7 BULK-df99e795
15800 Bulk Product 66f43055 Toys & Games $20.38 260 3.9 41 BULK-a21a7816
15801 Bulk Product 09f23032 Clothing $57.84 306 1.5 16 BULK-8cd38f83
15802 Bulk Product fe0e3346 Electronics $965.29 419 0.4 13 BULK-4bdb6f3e
15803 Bulk Product 2377b21a Books $454.27 364 0.3 33 BULK-32d3b2d3
15804 Bulk Product 2f4e750f Clothing $903.36 396 3.7 62 BULK-bc44e688
15805 Bulk Product 65a6b46b Electronics $608.03 165 1.4 19 BULK-57d7f768
15806 Bulk Product 044e3bdd Home & Garden $294.81 336 2.7 70 BULK-c6b5c0c0
15807 Bulk Product 14a4dd07 Books $957.74 480 4.1 81 BULK-5b1780ca
15808 Bulk Product b70922f2 Books $213.73 451 1.4 71 BULK-421c02ba
15809 Bulk Product 473d4e00 Electronics $134.49 205 3.4 25 BULK-ab7c2e55
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