Efficient Pagination with Skip/Take

Efficient pagination using OFFSET-FETCH on SQL Server.

Execution Time

74 ms

Page Size

50

Current Page

133 / 489

Total Records

24441

Items per page: 25 50 100 200

Page 133 Results Showing 6601 - 6650 of 24441

ID Name Category Price Stock Rating Reviews SKU
7160 Bulk Product 5e3c6951 Toys & Games $923.11 112 2.5 80 BULK-f335f259
7161 Bulk Product 36120d80 Sports & Outdoors $385.23 179 0.7 14 BULK-554a8328
7162 Bulk Product de0e30ba Clothing $802.86 173 0.5 53 BULK-5d78f363
7163 Bulk Product ce913e72 Toys & Games $645.93 494 3.2 18 BULK-f714d5c2
7164 Bulk Product 480db72b Home & Garden $509.92 447 0.0 22 BULK-cf664baa
7165 Bulk Product 509e1df3 Clothing $817.62 144 0.9 47 BULK-644895f9
7166 Bulk Product 5d7aabec Home & Garden $118.33 10 4.1 20 BULK-443c13f9
7167 Bulk Product 977efc13 Toys & Games $496.13 344 2.0 10 BULK-16e18285
7168 Bulk Product a452b7ff Clothing $556.94 496 4.6 16 BULK-0b1e1c93
7169 Bulk Product c9b92ca8 Electronics $220.19 262 0.8 1 BULK-30edd431
7170 Bulk Product 31f01fdd Clothing $628.50 405 0.3 52 BULK-bdfb4699
7171 Bulk Product 1b2d8ae5 Books $688.55 332 2.8 0 BULK-aecf2648
7172 Bulk Product 856a998a Clothing $975.07 252 0.5 75 BULK-0484a196
7173 Bulk Product 3b99a6cc Sports & Outdoors $109.05 442 1.2 33 BULK-48d9d2e6
7174 Bulk Product be0f195c Home & Garden $59.80 380 0.5 38 BULK-dcaa22bf
7175 Bulk Product e5cd9817 Clothing $365.07 170 4.9 45 BULK-9c3096eb
7176 Bulk Product db4352d2 Toys & Games $537.86 62 4.2 99 BULK-4a74433b
7177 Bulk Product 659e481f Home & Garden $54.61 317 4.4 55 BULK-412e83bd
7178 Bulk Product 4d0e85b8 Sports & Outdoors $691.98 498 1.0 90 BULK-c12a30bd
7179 Bulk Product 3180ecfb Books $540.54 454 1.1 27 BULK-d84616a3
7180 Bulk Product d85d8535 Toys & Games $992.00 403 0.5 20 BULK-cf99fafa
7181 Bulk Product 8667b043 Clothing $81.15 283 2.0 73 BULK-8cd39500
7182 Bulk Product 38c88010 Toys & Games $363.86 272 4.9 71 BULK-c4aae766
7183 Bulk Product 26ce2930 Clothing $137.90 145 4.4 31 BULK-1abc9415
7184 Bulk Product 74e0a0c7 Books $31.67 110 4.9 42 BULK-27799d16
7185 Bulk Product f1b946e2 Toys & Games $998.14 200 3.8 61 BULK-1bbbcb4d
7186 Bulk Product c906edbd Sports & Outdoors $485.11 184 3.0 5 BULK-9e920270
7187 Bulk Product 083e1588 Books $160.82 344 2.1 44 BULK-f92c5cec
7188 Bulk Product b2094200 Clothing $927.63 299 2.0 14 BULK-a027c9d8
7189 Bulk Product 89c6396d Home & Garden $505.24 253 0.1 73 BULK-81677de0
7190 Bulk Product 1bc940ec Toys & Games $130.35 340 1.8 25 BULK-2b0cc9a1
7191 Bulk Product 12ec7af9 Electronics $996.16 91 2.6 27 BULK-85b67921
7192 Bulk Product 6123d603 Home & Garden $231.34 15 1.9 99 BULK-8cd6dd22
7193 Bulk Product 41b9f627 Electronics $502.49 0 4.1 59 BULK-74ae258b
7194 Bulk Product 9c2776c8 Books $507.74 152 2.6 81 BULK-7cda2cb2
7195 Bulk Product a85ec2aa Home & Garden $470.29 483 3.2 3 BULK-cb951e20
7196 Bulk Product a5442ece Sports & Outdoors $877.34 116 0.8 11 BULK-00a2b874
7197 Bulk Product 4c224796 Electronics $17.89 347 0.6 98 BULK-11e5a323
7198 Bulk Product 8885ed5e Toys & Games $373.28 212 4.1 63 BULK-761c25e9
7199 Bulk Product aa9f99f6 Electronics $839.17 109 4.6 4 BULK-49fd1a95
7200 Bulk Product c89c927a Toys & Games $266.48 46 2.0 40 BULK-a59a3e78
7201 Bulk Product ca488c2a Clothing $393.33 80 4.1 39 BULK-1d5e4389
7202 Bulk Product e09c8e97 Clothing $237.15 364 0.6 21 BULK-a35eacd6
7203 Bulk Product 59d1102d Sports & Outdoors $839.18 195 2.4 89 BULK-6dbef5aa
7204 Bulk Product ce866757 Home & Garden $390.04 296 4.7 30 BULK-1d86d149
7205 Bulk Product 1cd85988 Home & Garden $161.61 358 0.6 57 BULK-d1294cb2
7206 Bulk Product f85eef5d Electronics $380.83 70 4.3 14 BULK-e429fca2
7207 Bulk Product bf37684f Clothing $720.40 92 0.5 2 BULK-c7467442
7208 Bulk Product ae125623 Home & Garden $571.47 94 4.9 43 BULK-e0fd2526
7209 Bulk Product 883d582b Electronics $881.09 39 0.8 36 BULK-e2e7eb86
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