0

I try this query in mysql and it works fine but the Query took 103.5772 sec

SELECT doctor, 
       SUM(medicine) medicine, 
       sum(radiology) radiology, 
       sum(lab) lab, 
       sum(act) act
FROM ( SELECT max(doctor) doctor, 
  sum( if( pm = 'F', cost, 0.00 ) ) medicine,
  sum( if( pm = 'R', cost, 0.00 ) ) radiology,
  sum( if( pm = 'L', cost, 0.00 ) ) lab,
  sum( if( pm = 'P', cost, 0.00 ) ) act
  FROM my_table
  GROUP BY no
  )t
GROUP BY doctor

my table has a large amount of data (nearly 2 million data)

when I try in .net, it has an error

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

can I increase the connection timeout?

n.b. I used this query to connect data

conn.ConnectionString = conection.getConnection();
MySqlDataAdapter da = new MySqlDataAdapter(query, conn);
da.Fill(ds);
return ds;
4

2 に答える 2

3

This is not a Connection Timeout, it is timing out on the command due to your data. Adjust the timeout as below;

Command.CommandTimeout = 300;

For more information : SqlCommand.CommandTimeout Property

I would also suggest you look at your indexes to see if you can optimise the query.

于 2012-12-06T14:16:48.437 に答える
-1

you could user the SqlCommand.CommandTimeout Property:

SqlCommand.CommandTimeout = 300;

于 2012-12-06T14:17:36.287 に答える