IsUserInRole too slow - ASP.NET
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
might be best asked here Codeproject asp.net forum[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
-
might be best asked here Codeproject asp.net forum[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
Find out what part exactly takes so much time. Perhaps there are many entries in the table that assigns the roles to the users. That can slow down the queries and in that case a lot can be done by trying to add or optimize the indices of the tables involved.
I'm invincible, I can't be vinced
-
Find out what part exactly takes so much time. Perhaps there are many entries in the table that assigns the roles to the users. That can slow down the queries and in that case a lot can be done by trying to add or optimize the indices of the tables involved.
I'm invincible, I can't be vinced
-
I dont have SQL profiler. But well made point. Will look into it. The total users in my app is less than 100 anyhow. Shouldn't be taking that long! Will investigate.
And if that does not work, you can still try to reduce the calls by getting the roles assigned to the current user and buffering the result. The simple way to do that would be to send off the query early (let's say in Page_Load()) and simply put the result into a member variable of the page, so that you can use it until the page's lifecycle ends.
I'm invincible, I can't be vinced
-
And if that does not work, you can still try to reduce the calls by getting the roles assigned to the current user and buffering the result. The simple way to do that would be to send off the query early (let's say in Page_Load()) and simply put the result into a member variable of the page, so that you can use it until the page's lifecycle ends.
I'm invincible, I can't be vinced
I am using Page_load currently. The code came from previous developer. There is a lot of calling for IsUserInRole so that definitely can improve performance if I remove them. But I am looking for a more elegant solution now that solves the problem of slow IsUserInRole. If not, your suggestion would be my best bet.
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
sharp_k wrote:
My question is can it be made faster?
Yes, as can getting an answer to your question: by posing it in the correct forum.
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
I am using Page_load currently. The code came from previous developer. There is a lot of calling for IsUserInRole so that definitely can improve performance if I remove them. But I am looking for a more elegant solution now that solves the problem of slow IsUserInRole. If not, your suggestion would be my best bet.
Reducing the number of queries and buffering the result (if needed) already is far less wasteful. Also you should look what the other guy needed so many queries for. Sounds like he smeared the logic all over the place. This surely can be consolidated or replaced by a more efficient logic. Repeatedly calling IsUserInRole sounds a little too primitive and wasteful.
I'm invincible, I can't be vinced
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
Yes, cache the answer. Or find another way.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun -
Reducing the number of queries and buffering the result (if needed) already is far less wasteful. Also you should look what the other guy needed so many queries for. Sounds like he smeared the logic all over the place. This surely can be consolidated or replaced by a more efficient logic. Repeatedly calling IsUserInRole sounds a little too primitive and wasteful.
I'm invincible, I can't be vinced
What basically the logic is right now, every page check for IsUserInRole and not just for one role. There are pages which can be accessed by two or three roles. If the user is in that role, he is allowed access otherwise not. It does not seem like that wasteful. But since IsUserInRole is slow, it needs to be made better. Ever page you visit is slow just because of it! So I can see now if I use cache even for single user, at least all the subsequent clicks will be faster.