-
-
Notifications
You must be signed in to change notification settings - Fork 97
Table scans on idsrv.Tokens table when querying for expired tokens #89
Comments
Do you have a proposed change to the DbContext code add this index? |
Just noticed this issue as well. The EF code created a query of tokens which is not needed the delete could be done without having to return the data. I think this is hard to do in EF. It make sense to just execute this as RAW SQL. If I get time soon I'll submit a PR for this. |
I think this comes from the code that looks for expired tokens. I'd ideally like a fix that can be configured in the DbContext's configure APIs (Build or whatever it's called), rather than something that's DB-specific (such as raw SQL). |
Would using something like EF Extended work? https://github.com/loresoft/EntityFramework.Extended/wiki/Batch-Update-and-Delete On Fri, May 13, 2016 at 8:24 AM, Brock Allen [email protected]
|
Not sure -- what's the support on that? Does it target the same DBs that EF supports? |
EF Extended package supports the same DBs as EF and it has a dependency on https://www.nuget.org/packages/EntityFramework.Extended/ On Fri, May 13, 2016 at 8:38 AM, Brock Allen [email protected]
|
Ok, possibly then. I don't know how much work it is to show me what it'd look like. Also, will this package allow indexes/unique constraints to be added? |
Let me know what you think. |
Any news on when the 3.0.0 release with this fix will be released @brockallen ? |
After we get IdentityServer4 released. |
We are using EntityFramework persistence for IdentityServer3 tokens and I've noticed frequent queries for expired tokens against idsrv.Tokens that are in the form of:
There's currently no index that will satisfy this query so it performs a table scan instead.
I'm proposing we change Token.cs to instead have a unique index on [Key] and [TokenType] columns and a non-unique clustered index on [Expiry] to help with the range query above.
The updated Token class might look like the one below based on what I've read here: https://msdn.microsoft.com/en-us/data/jj591583 and https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.indexattribute(v=vs.113).aspx.
The text was updated successfully, but these errors were encountered: