0

I work with C# and when to list very users in dropdown I should wait for a long time. Are 11.100 users to list.

I try use the DropDownListFor with select2 for the can be possible search:

@Html.DropDownListFor(m => m.IDUser, ListUsers(), new { @class = "form-control input-sm select2" })
@Html.ValidationMessageFor(m => m.IDUser)

The function ListUsers() given by:

IQueryable<Usuario> query;
query = from user in User
        join address in Address on user.Id equals address.IDUser
        where address.State == address
        select user;
return query.ToList();

This image show how the wait happened: perform

In the region 1 I click in the dropdown and selected the first user.

In the region 2 I scroll over the dropdown to the last user and selected him.

In the region 3 I click again in the dropdown and was the interval to show the dropdown.

Additional information: The interval of time to execute the function ListUser() that is related with region 3 is: timing

Then, we can see that time of search is lower than time of wait.

I would like to understand the why this is happened. - Why the dropdown is with too large delay? - How can I should be resolve this?

OBS: Sorry for my English.

natielle
  • 380
  • 3
  • 14
  • What does the code for: ListarUsuario() look like ? ... and can you also tell us how many rows you are trying to put into the DropDownList ? (your english is perfectly understandable btw) –  Apr 16 '20 at 02:01
  • Are 11.100 rows. And the function ListarUsuario is a SELECT with one join. Thank you! – natielle Apr 16 '20 at 02:08
  • If I were you, I would begin to examine the individual parts of what is going on. First of all, check how long the database query takes. If that's fine, then see how long it takes to populate the dropdownlist. My hunch is that it is the database query. But it would help alot if you add some code sections to your question, and explain in more detail what your setup looks like. –  Apr 16 '20 at 02:14
  • I added the code for the UserList () function to the question. And I believe that what is taking longer is select2 because it is what appears in the interaction that I do with the dropdown (look at the image). – natielle Apr 16 '20 at 02:20
  • I can see what you mean from your screenshot. But I cannot tell if the time is spent on the server or in the browser to render the data. You can figure that out by seeing in the Network tab in your browser, if there is request to the backend that takes a long time. That way you can narrow down the problem to a specific place (server or browser) .. and move on to isolate further from there. –  Apr 16 '20 at 02:25
  • Thanks for the tip, I did it. And, apparently, the list function is not taking long. I added the function time to the question. – natielle Apr 16 '20 at 02:45

0 Answers0