{"action":"created","issue":{"url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/466","labels_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/466/labels{/name}","comments_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/466/comments","events_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/466/events","html_url":"https://github.com/aspnetboilerplate/aspnetboilerplate/issues/466","id":71932687,"number":466,"title":"Long duration of GetScripts call","user":{"login":"easyest","id":6928101,"avatar_url":"https://avatars.githubusercontent.com/u/6928101?v=3","gravatar_id":"","url":"https://api.github.com/users/easyest","html_url":"https://github.com/easyest","followers_url":"https://api.github.com/users/easyest/followers","following_url":"https://api.github.com/users/easyest/following{/other_user}","gists_url":"https://api.github.com/users/easyest/gists{/gist_id}","starred_url":"https://api.github.com/users/easyest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/easyest/subscriptions","organizations_url":"https://api.github.com/users/easyest/orgs","repos_url":"https://api.github.com/users/easyest/repos","events_url":"https://api.github.com/users/easyest/events{/privacy}","received_events_url":"https://api.github.com/users/easyest/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/labels/enhancement","name":"enhancement","color":"c7def8"}],"state":"open","locked":false,"assignee":{"login":"hikalkan","id":1210527,"avatar_url":"https://avatars.githubusercontent.com/u/1210527?v=3","gravatar_id":"","url":"https://api.github.com/users/hikalkan","html_url":"https://github.com/hikalkan","followers_url":"https://api.github.com/users/hikalkan/followers","following_url":"https://api.github.com/users/hikalkan/following{/other_user}","gists_url":"https://api.github.com/users/hikalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/hikalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikalkan/subscriptions","organizations_url":"https://api.github.com/users/hikalkan/orgs","repos_url":"https://api.github.com/users/hikalkan/repos","events_url":"https://api.github.com/users/hikalkan/events{/privacy}","received_events_url":"https://api.github.com/users/hikalkan/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/milestones/22","html_url":"https://github.com/aspnetboilerplate/aspnetboilerplate/milestones/ABP%20v0.7.0","labels_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/milestones/22/labels","id":1030646,"number":22,"title":"ABP v0.7.0","description":"","creator":{"login":"hikalkan","id":1210527,"avatar_url":"https://avatars.githubusercontent.com/u/1210527?v=3","gravatar_id":"","url":"https://api.github.com/users/hikalkan","html_url":"https://github.com/hikalkan","followers_url":"https://api.github.com/users/hikalkan/followers","following_url":"https://api.github.com/users/hikalkan/following{/other_user}","gists_url":"https://api.github.com/users/hikalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/hikalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikalkan/subscriptions","organizations_url":"https://api.github.com/users/hikalkan/orgs","repos_url":"https://api.github.com/users/hikalkan/repos","events_url":"https://api.github.com/users/hikalkan/events{/privacy}","received_events_url":"https://api.github.com/users/hikalkan/received_events","type":"User","site_admin":false},"open_issues":30,"closed_issues":1,"state":"open","created_at":"2015-03-20T09:11:56Z","updated_at":"2015-07-30T06:00:09Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2015-04-29T17:10:42Z","updated_at":"2015-08-18T20:01:01Z","closed_at":null,"body":"My Web server and Database server are on separated machines. When loading the page, request to `GetScripts` takes more than 4 seconds:\r\n![image](https://cloud.githubusercontent.com/assets/6928101/7396373/28ea7dfa-eea9-11e4-9844-1c01ab91ce76.png)\r\n\r\nWhat is strange that there lots of repeated database queries. The page is completely empty, no database related content on the page. Controller action is protected with `AbpAuthorize` attribute, there are no services used in the controller method. Whole system has 8 permissions, and the user that is logged in has only 2 of them.\r\nThis query is executed exactly 20 times:\r\n```SQL\r\nexec sp_executesql N'SELECT \r\n    [Limit1].[C1] AS [C1], \r\n    [Limit1].[Id] AS [Id], \r\n    [Limit1].[Name] AS [Name], \r\n    [Limit1].[IsGranted] AS [IsGranted], \r\n    [Limit1].[CreationTime] AS [CreationTime], \r\n    [Limit1].[CreatorUserId] AS [CreatorUserId], \r\n    [Limit1].[UserId] AS [UserId]\r\n    FROM ( SELECT TOP (1) \r\n        [Extent1].[Id] AS [Id], \r\n        [Extent1].[Name] AS [Name], \r\n        [Extent1].[IsGranted] AS [IsGranted], \r\n        [Extent1].[CreationTime] AS [CreationTime], \r\n        [Extent1].[CreatorUserId] AS [CreatorUserId], \r\n        [Extent1].[UserId] AS [UserId], \r\n        ''0X0X'' AS [C1]\r\n        FROM [dbo].[AbpPermissions] AS [Extent1]\r\n        WHERE ([Extent1].[Discriminator] = N''UserPermissionSetting'') AND ([Extent1].[UserId] = @p__linq__0) AND ([Extent1].[Name] = @p__linq__1) AND ([Extent1].[IsGranted] = @p__linq__2)\r\n    )  AS [Limit1]',N'@p__linq__0 bigint,@p__linq__1 nvarchar(4000),@p__linq__2 bit',@p__linq__0=1,@p__linq__1=N'System_SuperUser',@p__linq__2=1\r\n```\r\nThis one also 20 times:\r\n```SQL\r\nexec sp_executesql N'SELECT TOP (1) \r\n    [Extent1].[Id] AS [Id], \r\n    [Extent1].[TenantId] AS [TenantId], \r\n    [Extent1].[Name] AS [Name], \r\n    [Extent1].[Surname] AS [Surname], \r\n    [Extent1].[UserName] AS [UserName], \r\n    [Extent1].[Password] AS [Password], \r\n    [Extent1].[EmailAddress] AS [EmailAddress], \r\n    [Extent1].[IsEmailConfirmed] AS [IsEmailConfirmed], \r\n    [Extent1].[EmailConfirmationCode] AS [EmailConfirmationCode], \r\n    [Extent1].[PasswordResetCode] AS [PasswordResetCode], \r\n    [Extent1].[LastLoginTime] AS [LastLoginTime], \r\n    [Extent1].[IsActive] AS [IsActive], \r\n    [Extent1].[IsDeleted] AS [IsDeleted], \r\n    [Extent1].[DeleterUserId] AS [DeleterUserId], \r\n    [Extent1].[DeletionTime] AS [DeletionTime], \r\n    [Extent1].[LastModificationTime] AS [LastModificationTime], \r\n    [Extent1].[LastModifierUserId] AS [LastModifierUserId], \r\n    [Extent1].[CreationTime] AS [CreationTime], \r\n    [Extent1].[CreatorUserId] AS [CreatorUserId]\r\n    FROM [dbo].[AbpUsers] AS [Extent1]\r\n    WHERE ((([Extent1].[TenantId] IS NULL) AND (@DynamicFilterParam_MayHaveTenant_tenantId IS NULL)) OR (([Extent1].[TenantId] IS NOT NULL) AND ([Extent1].[TenantId] = @DynamicFilterParam_MayHaveTenant_tenantId)) OR (@DynamicFilterParam_MayHaveTenant_DynamicFilterIsDisabled IS NOT NULL)) AND (([Extent1].[IsDeleted] = @DynamicFilterParam_SoftDelete_IsDeleted) OR (@DynamicFilterParam_SoftDelete_DynamicFilterIsDisabled IS NOT NULL)) AND (1 = [Extent1].[Id])',N'@DynamicFilterParam_MayHaveTenant_tenantId int,@DynamicFilterParam_MayHaveTenant_DynamicFilterIsDisabled bit,@DynamicFilterParam_SoftDelete_IsDeleted bit,@DynamicFilterParam_SoftDelete_DynamicFilterIsDisabled bit',@DynamicFilterParam_MayHaveTenant_tenantId=NULL,@DynamicFilterParam_MayHaveTenant_DynamicFilterIsDisabled=NULL,@DynamicFilterParam_SoftDelete_IsDeleted=0,@DynamicFilterParam_SoftDelete_DynamicFilterIsDisabled=NULL\r\n```\r\n\r\nThis query is executed \"only\" 10 times:\r\n```SQL\r\nexec sp_executesql N'SELECT \r\n    [Limit1].[C1] AS [C1], \r\n    [Limit1].[Id] AS [Id], \r\n    [Limit1].[Name] AS [Name], \r\n    [Limit1].[IsGranted] AS [IsGranted], \r\n    [Limit1].[CreationTime] AS [CreationTime], \r\n    [Limit1].[CreatorUserId] AS [CreatorUserId], \r\n    [Limit1].[RoleId] AS [RoleId]\r\n    FROM ( SELECT TOP (1) \r\n        [Extent1].[Id] AS [Id], \r\n        [Extent1].[Name] AS [Name], \r\n        [Extent1].[IsGranted] AS [IsGranted], \r\n        [Extent1].[CreationTime] AS [CreationTime], \r\n        [Extent1].[CreatorUserId] AS [CreatorUserId], \r\n        [Extent1].[RoleId] AS [RoleId], \r\n        ''0X0X'' AS [C1]\r\n        FROM [dbo].[AbpPermissions] AS [Extent1]\r\n        WHERE ([Extent1].[Discriminator] = N''RolePermissionSetting'') AND ([Extent1].[RoleId] = @p__linq__0) AND ([Extent1].[Name] = @p__linq__1) AND ([Extent1].[IsGranted] = @p__linq__2)\r\n    )  AS [Limit1]',N'@p__linq__0 int,@p__linq__1 nvarchar(4000),@p__linq__2 bit',@p__linq__0=1,@p__linq__1=N'System_SuperUser',@p__linq__2=1\r\n```\r\nI understand that for SPA system it does not make big difference, but it is really painful for MVC."},"comment":{"url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/comments/132333359","html_url":"https://github.com/aspnetboilerplate/aspnetboilerplate/issues/466#issuecomment-132333359","issue_url":"https://api.github.com/repos/aspnetboilerplate/aspnetboilerplate/issues/466","id":132333359,"user":{"login":"guilmori","id":9451512,"avatar_url":"https://avatars.githubusercontent.com/u/9451512?v=3","gravatar_id":"","url":"https://api.github.com/users/guilmori","html_url":"https://github.com/guilmori","followers_url":"https://api.github.com/users/guilmori/followers","following_url":"https://api.github.com/users/guilmori/following{/other_user}","gists_url":"https://api.github.com/users/guilmori/gists{/gist_id}","starred_url":"https://api.github.com/users/guilmori/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guilmori/subscriptions","organizations_url":"https://api.github.com/users/guilmori/orgs","repos_url":"https://api.github.com/users/guilmori/repos","events_url":"https://api.github.com/users/guilmori/events{/privacy}","received_events_url":"https://api.github.com/users/guilmori/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T20:01:01Z","updated_at":"2015-08-18T20:01:01Z","body":"I suggest that ABP could expose a \"ClearPermissionsCache\" Web API endpoint.\r\nWhen you make a GET http request to this api, permissions cache would be reloaded fresh from database.\r\nThat would be useful for an admin to call this from a web browser, instead of having to restart the whole website."}}