gpt4 book ai didi

c# - 连接的主机未能响应,超时已过

转载 作者:行者123 更新时间:2023-11-29 08:41:13 24 4
gpt4 key购买 nike

我在 mysql 中尝试这个查询,它工作正常,但查询花费了 103.5772 秒

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

我的表数据量很大(近200万条数据)

当我在 .net 中尝试时,出现错误

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

我可以增加连接超时吗?

n.b.我用这个查询来连接数据

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

最佳答案

这不是连接超时,而是由于您的数据导致命令超时。如下调整超时;

Command.CommandTimeout = 300;

了解更多信息:SqlCommand.CommandTimeout Property

我还建议您查看索引,看看是否可以优化查询。

关于c# - 连接的主机未能响应,超时已过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13745433/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com