Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

18 ms

Page Size

50

Current Page

346 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 346 Results Showing 17251 - 17300 of 24441

ID Name Category Price Stock Rating Reviews SKU
17810 Bulk Product 5d5fe33e Sports & Outdoors $265.18 197 0.8 36 BULK-1fce3ee0
17811 Bulk Product 17129220 Toys & Games $919.36 15 3.4 41 BULK-89f1710c
17812 Bulk Product 9e958439 Clothing $33.96 442 2.7 26 BULK-157baacb
17813 Bulk Product e31eb435 Books $288.05 98 4.6 65 BULK-264d7bd1
17814 Bulk Product c6db853a Books $78.16 222 3.4 90 BULK-d9f26e4d
17815 Bulk Product 9bc5d2ec Electronics $222.10 174 0.7 70 BULK-f4a1da6f
17816 Bulk Product 997820f1 Books $207.39 481 0.7 72 BULK-664921e5
17817 Bulk Product df23d46c Electronics $764.29 361 1.4 62 BULK-7c069bce
17818 Bulk Product 022b3ea9 Clothing $589.49 284 1.7 33 BULK-50c858b0
17819 Bulk Product 9fba801c Clothing $865.77 496 3.5 56 BULK-0f92f123
17820 Bulk Product 593edc23 Books $338.53 288 0.0 93 BULK-bde5b058
17821 Bulk Product d91b7be2 Electronics $287.64 60 4.0 59 BULK-7000932e
17822 Bulk Product 795f9a38 Home & Garden $370.65 107 2.4 18 BULK-ef375a5e
17823 Bulk Product 24252430 Electronics $154.87 116 0.9 45 BULK-43f594c2
17824 Bulk Product 17720c2e Books $858.47 76 4.8 26 BULK-02a53e80
17825 Bulk Product d16fad68 Electronics $198.26 418 1.8 77 BULK-a3d687e8
17826 Bulk Product ecdcfe3c Books $986.55 269 2.5 72 BULK-c608ee35
17827 Bulk Product f9bc7aa1 Books $264.89 385 1.4 4 BULK-833f7ec9
17828 Bulk Product 1b11fbbf Toys & Games $735.72 156 1.2 7 BULK-9323f28f
17829 Bulk Product fe1dec8a Books $948.56 277 2.8 53 BULK-0df9e211
17830 Bulk Product 1df0261c Sports & Outdoors $719.22 378 1.8 39 BULK-ddb9c35e
17831 Bulk Product b62465f6 Toys & Games $1,008.09 28 0.4 2 BULK-638861b5
17832 Bulk Product 1d2ad240 Sports & Outdoors $612.64 185 0.2 22 BULK-03bdc82d
17833 Bulk Product fd50f6d6 Sports & Outdoors $636.01 92 2.4 62 BULK-0f78527d
17834 Bulk Product da63d8df Clothing $244.02 283 4.5 88 BULK-35a26931
17835 Bulk Product a807ae15 Clothing $448.44 150 0.3 89 BULK-b05255f3
17836 Bulk Product 5d9b0008 Clothing $259.35 382 0.8 67 BULK-60352f00
17837 Bulk Product 8094995f Clothing $228.06 342 3.8 75 BULK-dbf2e930
17838 Bulk Product f66190a2 Books $564.61 102 4.5 92 BULK-a62c16fd
17839 Bulk Product 326eccb4 Home & Garden $862.06 185 2.2 89 BULK-47c89a34
17840 Bulk Product 6c5112b8 Electronics $564.40 73 0.1 46 BULK-bf38669f
17841 Bulk Product 812c06ba Home & Garden $725.44 159 4.8 45 BULK-8e2477ae
17842 Bulk Product 37153f84 Books $235.01 180 0.2 51 BULK-73940d8a
17843 Bulk Product 0e9a741e Toys & Games $1,006.86 234 4.0 60 BULK-89076c35
17844 Bulk Product 49b34a42 Electronics $474.90 209 2.8 93 BULK-7e86be02
17845 Bulk Product d12999f7 Home & Garden $310.68 416 0.1 99 BULK-903372fd
17846 Bulk Product bcabff93 Electronics $505.45 244 3.8 86 BULK-c511e9f3
17847 Bulk Product 9bc09709 Clothing $698.90 258 0.6 37 BULK-940f569b
17848 Bulk Product 90c956fa Sports & Outdoors $897.80 313 0.3 29 BULK-eb29aa85
17849 Bulk Product 89ff54cb Books $500.24 155 3.8 70 BULK-6f2623ac
17850 Bulk Product 08f8252f Clothing $301.13 225 3.6 43 BULK-4ce2ff1c
17851 Bulk Product d4ec4274 Home & Garden $266.97 73 4.3 81 BULK-a4a3c6f5
17852 Bulk Product c0542603 Clothing $421.49 200 3.7 94 BULK-40d58a8a
17853 Bulk Product aa1d7881 Sports & Outdoors $757.88 89 3.2 97 BULK-f36872ed
17854 Bulk Product 476c76be Sports & Outdoors $898.15 355 2.6 77 BULK-c00b38d5
17855 Bulk Product 5e5de3a3 Books $203.98 4 3.7 2 BULK-f7886fb6
17856 Bulk Product 18b03ba0 Clothing $93.05 429 0.9 7 BULK-4da67144
17857 Bulk Product 8b434758 Home & Garden $178.01 477 0.5 49 BULK-693c9439
17858 Bulk Product feb2e2d0 Toys & Games $485.24 324 4.5 19 BULK-093b1118
17859 Bulk Product 310a69af Electronics $561.32 378 2.2 7 BULK-c51f0268
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