Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

12 ms

Page Size

50

Current Page

301 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 301 Results Showing 15001 - 15050 of 24441

ID Name Category Price Stock Rating Reviews SKU
15560 Bulk Product 4c0af675 Electronics $849.46 493 2.2 51 BULK-a4057eb0
15561 Bulk Product ee894a45 Toys & Games $814.36 284 1.3 43 BULK-0f9535d8
15562 Bulk Product 82557e1f Sports & Outdoors $409.29 184 2.0 39 BULK-beefff4d
15563 Bulk Product 81d8353d Toys & Games $882.46 484 1.4 66 BULK-4c1822cc
15564 Bulk Product 4db9ceff Home & Garden $542.01 331 4.1 44 BULK-014e5b48
15565 Bulk Product 2620e24c Clothing $147.34 174 2.0 15 BULK-89c0efaa
15566 Bulk Product e994d3d0 Books $276.12 417 3.5 73 BULK-6987a75c
15567 Bulk Product 89eebb8b Electronics $96.40 233 2.5 92 BULK-1ebfec48
15568 Bulk Product f70e9a12 Clothing $140.86 230 1.3 67 BULK-8e25a87f
15569 Bulk Product 2a800260 Clothing $519.83 282 0.4 99 BULK-fdc2c568
15570 Bulk Product c38f1ae1 Sports & Outdoors $384.61 168 0.1 1 BULK-68df6c4b
15571 Bulk Product 495e1b4d Toys & Games $279.37 267 2.7 20 BULK-4238774a
15572 Bulk Product 4bea1552 Clothing $187.96 195 2.4 27 BULK-1e1bd93b
15573 Bulk Product 0c478298 Books $396.20 215 1.5 65 BULK-43ce64c5
15574 Bulk Product d8765f7d Clothing $646.67 36 0.2 65 BULK-e51dde51
15575 Bulk Product 55dc128c Books $928.49 408 3.0 6 BULK-4c2ee116
15576 Bulk Product 7d2f232f Electronics $423.67 127 1.4 59 BULK-8b765262
15577 Bulk Product a9bfe5dd Electronics $296.76 118 1.3 11 BULK-f9bf53be
15578 Bulk Product bdd536b5 Home & Garden $400.46 51 2.9 97 BULK-7a82c90c
15579 Bulk Product b11d1e57 Books $153.31 140 2.4 43 BULK-c25a84cb
15580 Bulk Product 70437161 Home & Garden $854.76 322 2.5 98 BULK-961543b8
15581 Bulk Product 63f21d0a Toys & Games $697.63 140 1.4 80 BULK-a13bba13
15582 Bulk Product e64ff499 Sports & Outdoors $165.25 57 1.6 27 BULK-aa2eed9c
15583 Bulk Product 36eff9d8 Books $26.91 386 4.2 49 BULK-08846dd7
15584 Bulk Product 78cd725a Clothing $184.58 389 0.2 94 BULK-ed832693
15585 Bulk Product a77e3b21 Sports & Outdoors $840.93 114 5.0 19 BULK-c316d670
15586 Bulk Product 8ee50321 Sports & Outdoors $116.94 189 4.7 89 BULK-e8b3d4ca
15587 Bulk Product d8f55046 Books $884.77 386 2.5 92 BULK-4b4d949e
15588 Bulk Product b37b95dd Sports & Outdoors $177.12 398 1.1 8 BULK-fb5ed161
15589 Bulk Product d12e0820 Electronics $424.34 424 4.4 39 BULK-79329297
15590 Bulk Product 05245ff9 Toys & Games $158.20 289 4.0 15 BULK-2b9a425a
15591 Bulk Product 8604338d Toys & Games $756.35 247 2.9 74 BULK-057d926e
15592 Bulk Product 74ed5621 Clothing $553.81 416 2.5 53 BULK-99dfff23
15593 Bulk Product 1e7c0918 Toys & Games $248.72 247 4.3 25 BULK-c896e76e
15594 Bulk Product 9fdf68ab Clothing $239.21 39 2.9 51 BULK-facf0465
15595 Bulk Product ba4b7f03 Electronics $403.57 497 0.7 26 BULK-d778f7c1
15596 Bulk Product 2875211c Toys & Games $219.04 273 2.0 14 BULK-650a7c16
15597 Bulk Product c22113f8 Sports & Outdoors $522.48 195 0.9 49 BULK-88985369
15598 Bulk Product a44d24aa Clothing $890.14 228 0.6 50 BULK-5f17c5c9
15599 Bulk Product 0031a61a Toys & Games $726.28 80 2.0 18 BULK-2d573c85
15600 Bulk Product 80d71901 Toys & Games $588.54 335 4.2 44 BULK-4d99d820
15601 Bulk Product 2ac57f03 Toys & Games $634.17 73 3.3 73 BULK-e36fdfc0
15602 Bulk Product 479f1a67 Electronics $468.90 23 4.8 39 BULK-7c2af7e5
15603 Bulk Product 90de83f4 Electronics $551.95 385 0.0 65 BULK-fa319922
15604 Bulk Product ee8b1b0c Toys & Games $978.68 386 2.2 77 BULK-f270d62e
15605 Bulk Product b9e8cec3 Sports & Outdoors $221.93 118 1.5 35 BULK-96ae3fd4
15606 Bulk Product 742a3ddc Books $231.01 79 4.4 64 BULK-12b95cc5
15607 Bulk Product 327d7151 Toys & Games $78.09 293 4.0 30 BULK-29dd2033
15608 Bulk Product 0532a9fe Toys & Games $599.19 203 2.4 68 BULK-8e1a42b9
15609 Bulk Product a6ff2818 Books $616.02 32 0.0 74 BULK-c34d7082
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