Skip to content

Commit

Permalink
order by predicate to prevent table scan (IdentityServer#5092)
Browse files Browse the repository at this point in the history
  • Loading branch information
edmacdonald authored Apr 7, 2021
1 parent 997a6cd commit 3ff3b46
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.


Expand Down Expand Up @@ -76,7 +76,7 @@ protected virtual async Task RemoveGrantsAsync()
{
var expiredGrants = await _persistedGrantDbContext.PersistedGrants
.Where(x => x.Expiration < DateTime.UtcNow)
.OrderBy(x => x.Key)
.OrderBy(x => x.Expiration)
.Take(_options.TokenCleanupBatchSize)
.ToArrayAsync();

Expand Down Expand Up @@ -109,7 +109,7 @@ protected virtual async Task RemoveDeviceCodesAsync()
{
var expiredCodes = await _persistedGrantDbContext.DeviceFlowCodes
.Where(x => x.Expiration < DateTime.UtcNow)
.OrderBy(x => x.DeviceCode)
.OrderBy(x => x.Expiration)
.Take(_options.TokenCleanupBatchSize)
.ToArrayAsync();

Expand Down

0 comments on commit 3ff3b46

Please sign in to comment.