Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

26 ms

Page Size

50

Current Page

127 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 127 Results Showing 6301 - 6350 of 24441

ID Name Category Price Stock Rating Reviews SKU
6860 Bulk Product ca4dd5ef Clothing $541.66 379 1.4 21 BULK-65705ec3
6861 Bulk Product 9225376e Sports & Outdoors $762.69 88 3.1 51 BULK-cc79e9fa
6862 Bulk Product 63b95404 Sports & Outdoors $895.05 234 1.0 97 BULK-62ef6d4d
6863 Bulk Product 25d56e15 Clothing $411.97 251 4.4 62 BULK-b751fbfb
6864 Bulk Product e882336d Toys & Games $915.40 332 2.8 87 BULK-2314693a
6865 Bulk Product a527746c Sports & Outdoors $482.42 318 0.5 39 BULK-aee1d480
6866 Bulk Product 3e21df94 Sports & Outdoors $261.96 382 4.2 39 BULK-bd0ccad4
6867 Bulk Product 0625c67a Books $591.60 79 1.6 85 BULK-6cc043a1
6868 Bulk Product 555c0da4 Clothing $95.35 490 3.8 13 BULK-dae42f93
6869 Bulk Product 23bfb6db Books $899.23 93 4.2 1 BULK-ac5ae737
6870 Bulk Product cde7b369 Home & Garden $676.63 441 4.7 43 BULK-4353834f
6871 Bulk Product 729e2227 Electronics $186.23 42 2.7 55 BULK-a321384b
6872 Bulk Product 3cbe261d Clothing $537.97 395 1.7 53 BULK-af552a86
6873 Bulk Product 2c0ae475 Books $292.98 424 0.7 52 BULK-dc8c693b
6874 Bulk Product 580d5bee Home & Garden $327.24 157 3.7 4 BULK-d289cd40
6875 Bulk Product ac6c71ce Home & Garden $860.49 211 0.7 24 BULK-89c74d6c
6876 Bulk Product dc8d9d9c Electronics $12.74 333 0.9 83 BULK-5940e619
6877 Bulk Product 08e5f82f Clothing $246.48 33 3.0 19 BULK-8c06dc98
6878 Bulk Product 7d289e9d Clothing $706.27 460 3.7 45 BULK-8742c98c
6879 Bulk Product 9e8fe3b1 Toys & Games $158.88 29 3.7 83 BULK-83126554
6880 Bulk Product 05b66620 Electronics $872.50 426 2.5 21 BULK-a6237adf
6881 Bulk Product f52b0848 Sports & Outdoors $392.95 371 3.6 94 BULK-c0cf6412
6882 Bulk Product e2f79364 Clothing $281.66 13 0.0 90 BULK-6f27bc22
6883 Bulk Product cfcdf710 Sports & Outdoors $555.50 224 4.1 7 BULK-d5a43efb
6884 Bulk Product 3135acac Toys & Games $873.68 489 3.0 85 BULK-ef1af487
6885 Bulk Product 11278740 Home & Garden $987.56 239 0.2 2 BULK-836ce3bc
6886 Bulk Product d46afb72 Home & Garden $917.69 40 0.9 9 BULK-60060669
6887 Bulk Product 87dc2b9c Clothing $466.78 159 4.3 71 BULK-23adbdce
6888 Bulk Product b74994cc Clothing $47.09 325 1.9 37 BULK-4b75eadc
6889 Bulk Product 2e7f7279 Toys & Games $782.46 465 4.2 57 BULK-ea315867
6890 Bulk Product a1a56622 Clothing $164.57 402 4.7 2 BULK-51fc9ff3
6891 Bulk Product 108cbc65 Sports & Outdoors $393.26 218 0.2 77 BULK-3883a9cf
6892 Bulk Product 1d75d82b Books $190.42 349 3.1 17 BULK-04f4b91a
6893 Bulk Product f93a3062 Books $558.86 204 2.4 65 BULK-b1d38519
6894 Bulk Product c9ca6f05 Electronics $357.79 445 3.2 81 BULK-bd195b52
6895 Bulk Product 543dc86b Home & Garden $722.39 323 4.9 37 BULK-f90de1f6
6896 Bulk Product 367257c1 Home & Garden $962.82 186 3.9 31 BULK-f022f86d
6897 Bulk Product f197a3f6 Books $354.05 487 2.0 51 BULK-3c29dd86
6898 Bulk Product 05c349c9 Electronics $615.72 185 0.5 32 BULK-4d14df64
6899 Bulk Product 26fd22cd Electronics $570.21 167 2.7 40 BULK-a8c94572
6900 Bulk Product 23a9df2b Sports & Outdoors $999.61 220 1.4 9 BULK-87c9e48d
6901 Bulk Product 5ec92c35 Clothing $331.10 75 2.4 96 BULK-df438111
6902 Bulk Product f5992ba8 Books $480.26 203 4.2 29 BULK-c987070f
6903 Bulk Product eaa30a69 Home & Garden $988.06 142 2.5 26 BULK-11811dbc
6904 Bulk Product 80d3cd67 Toys & Games $877.56 100 1.4 41 BULK-8aa4068e
6905 Bulk Product 5ce77209 Toys & Games $978.26 257 1.6 51 BULK-d695181f
6906 Bulk Product 794d3b7d Electronics $808.28 136 3.7 38 BULK-45850f73
6907 Bulk Product ebd3c3cf Home & Garden $1,009.56 499 4.6 6 BULK-73f1ba45
6908 Bulk Product a873e3c6 Electronics $297.02 482 3.1 7 BULK-460e604a
6909 Bulk Product fdafc5f9 Toys & Games $127.43 490 2.3 86 BULK-146cdc38
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