{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Identity/issues/1030","repository_url":"https://api.github.com/repos/aspnet/Identity","labels_url":"https://api.github.com/repos/aspnet/Identity/issues/1030/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Identity/issues/1030/comments","events_url":"https://api.github.com/repos/aspnet/Identity/issues/1030/events","html_url":"https://github.com/aspnet/Identity/issues/1030","id":189426852,"number":1030,"title":"New AspNetUserTokens Table Column Width Issues","user":{"login":"eriksendc","id":8974354,"avatar_url":"https://avatars.githubusercontent.com/u/8974354?v=3","gravatar_id":"","url":"https://api.github.com/users/eriksendc","html_url":"https://github.com/eriksendc","followers_url":"https://api.github.com/users/eriksendc/followers","following_url":"https://api.github.com/users/eriksendc/following{/other_user}","gists_url":"https://api.github.com/users/eriksendc/gists{/gist_id}","starred_url":"https://api.github.com/users/eriksendc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eriksendc/subscriptions","organizations_url":"https://api.github.com/users/eriksendc/orgs","repos_url":"https://api.github.com/users/eriksendc/repos","events_url":"https://api.github.com/users/eriksendc/events{/privacy}","received_events_url":"https://api.github.com/users/eriksendc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-15T15:44:54Z","updated_at":"2016-11-16T13:51:52Z","closed_at":null,"body":"Hi All,\r\n\r\nMy team is just wrapping up migrating from RC1 to RTM. There's now a table called AspNetUserTokens that is being created. Here's the DDL for the table as it was created auto-magically for us:\r\n\r\n    CREATE TABLE [dbo].[AspNetUserTokens] (\r\n        [UserId]        NVARCHAR (450) NOT NULL,\r\n        [LoginProvider] NVARCHAR (450) NOT NULL,\r\n        [Name]          NVARCHAR (450) NOT NULL,\r\n        [Value]         NVARCHAR (MAX) NULL,\r\n        CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY CLUSTERED ([UserId] ASC, [LoginProvider] ASC, [Name] ASC)\r\n    );\r\n\r\nWhen testing the delta script for going to production I got this warning in SQL Server Management Studio:\r\n\r\n`Warning! The maximum key length is 900 bytes. The index 'PK_AspNetUserTokens' has maximum length of 2700 bytes. For some combination of large values, the insert/update operation will fail.`\r\n\r\nWhy are the lengths of the columns so large? It would seem that making `UserId`  be `NVARCHAR(36)` would be fine, given that it's 36 everywhere else. I see the length of `LoginProvider` matches the length of that column in `AspNetUserLogins`, but isn't 450 unnecessarily large? In practice the values are `Google` and `Facebook`, etc. Maybe the same is true of the `Name` column as well. Finally, using `NVARCHAR(MAX)` (using any column type with the length `MAX`) causes the database engine to have to determin if the length of the actual piece of data being stored for a particular row should be stored in the data page itself or outside of the data page. There is an unnecessary performance hit for using `NVARCHAR(MAX)` if the token's value will be something <= 4000 in practice. Why not put the value into `NVARCHAR(#)`, where # is the largest expected size of the token's value (again, if it is less than 4000 in practice).\r\n\r\nFor now we'll use the table as-is, but wanted to bubble up these thoughts for discussion.\r\n\r\nThanks!\r\n-Brian Eriksen"},"comment":{"url":"https://api.github.com/repos/aspnet/Identity/issues/comments/260951316","html_url":"https://github.com/aspnet/Identity/issues/1030#issuecomment-260951316","issue_url":"https://api.github.com/repos/aspnet/Identity/issues/1030","id":260951316,"user":{"login":"eriksendc","id":8974354,"avatar_url":"https://avatars.githubusercontent.com/u/8974354?v=3","gravatar_id":"","url":"https://api.github.com/users/eriksendc","html_url":"https://github.com/eriksendc","followers_url":"https://api.github.com/users/eriksendc/followers","following_url":"https://api.github.com/users/eriksendc/following{/other_user}","gists_url":"https://api.github.com/users/eriksendc/gists{/gist_id}","starred_url":"https://api.github.com/users/eriksendc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eriksendc/subscriptions","organizations_url":"https://api.github.com/users/eriksendc/orgs","repos_url":"https://api.github.com/users/eriksendc/repos","events_url":"https://api.github.com/users/eriksendc/events{/privacy}","received_events_url":"https://api.github.com/users/eriksendc/received_events","type":"User","site_admin":false},"created_at":"2016-11-16T13:51:52Z","updated_at":"2016-11-16T13:51:52Z","body":"By the way, we're not finding that data is ever insterted into AspNetUserTokens. What is it used for?"}}
{"actor":{"display_login":"eriksendc"}}