More than one query in a very slow request in the first C#request

Asked

Viewed 137 times

1

I have a method that requests data from the database and in this same method I call another method that also requests the database (mysql).

public class Viagem
{
    public int idViagem { get; set; }
    ...
    public Cidade origem { get; set; } 

public List<Viagem> getViagens(int p)
{
    Connection con = new Connection();
    string query = @"SELECT * FROM viagem"
    if (con.connect())
    {
          using (MySqlCommand cmd = new MySqlCommand(query, con.getConnection()))
          {
              MySqlDataReader reader = cmd.ExecuteReader();

              while (reader.Read())
              {
                  Viagem viagem = new Viagem();
                  Cidade cidade = new Cidade();
                  ...
                  viagem.origem = cidade.getCidade(Convert.toInt32(reader["cidade"]));
              }
     }

}

The getCity method has behavior similar to this getViagens. So when I have nested calls like this is taking too long on the GODADDY server, I have similar codes on other servers the problem does not happen. It’s taking more than 30 seconds for me to return 20 instances.

I need to set up something on the server to make it pooling properly?

Edited: The problem always occurs when I make the first request, the others, even if the values change, occur at an expected time. Any suggestions?

Solved: The godaddy fixes the session time in 5 minutes, disconnecting the non-active users for this time, so the first request always took a long time, the server having to leave the "standby" to only make the request. The solution I will create a task within the hosting itself so that I would request a page every 4 minutes and keep the server "awake".

Create task godaddy

  • 1

    Already ran this query directly in the database and checked if the time is taking?

  • Man, this happens to me, I use Godaddy and as incredible as I look I have several methods like yours, LOCALHOST keeps reading,.

  • Ideally you would run this query directly in the database to check whether the problem is in the database or in your application. After that we could try to help with the most appropriate solution to your problem.

  • The querys directly on the bench, including all joints using Join work quickly. And I have the same problem in production.

  • Did you hire a VPS or an application for Asp.net? In short, you have access to IIS either via dashboard or deploy only?

  • After the first call everything is normal, correct?

  • Yes, everything was normal, the problem was at the closing of the pool at godaddy.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.