我写了一个查询,它需要超过 30 秒。
我的代码:
MySqlConnection myConnection = new MySqlConnection(ConfigurationSettings.AppSettings["CollectiveIntelligence"]);
string query = @"SELECT TBL.NAME1,
TBL.NAME2
FROM (SELECT MLD1.LOGIN_NAME AS NAME1,
MLD2.LOGIN_NAME AS NAME2
FROM FEDERATED_M_LOGIN_DETAILS MLD1
JOIN FEDERATED_M_LOGIN_DETAILS MLD2
WHERE MLD1.LOGIN_NAME < MLD2.LOGIN_NAME
ORDER BY NAME1,NAME2) TBL
WHERE NOT EXISTS (SELECT USER_NAME1,
USER_NAME2
FROM CONNECTION C
WHERE (C.USER_NAME1 = TBL.NAME1 AND C.USER_NAME2 = TBL.NAME2));";
MySqlCommand myCommand = new MySqlCommand(query, myConnection);
//Open Connection
myConnection.Open();
myCommand.CommandTimeout = 0;
MySqlDataReader reader = myCommand.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
GridView1.DataSource = dt;
GridView1.DataBind();
myConnection.Close();
reader.Close();
发生错误
MySqlDataReader reader = myCommand.ExecuteReader();
错误消息:超时已过期。操作完成前超时时间已过或服务器无响应
如何增加asp.net的执行超时,使其执行查询/
[编辑]
当我点击解释它的显示是这样的
id select_type table type possible_keys key key_len ref rows Extra
1, SIMPLE, MLD1, ALL, , , , , 295, Using temporary; Using filesort
1, SIMPLE, MLD2, ALL, , , , , 295, Using where; Using join buffer
1, SIMPLE, C, index, , INDEX_CONNECTION, 94, , 30754, Using where; Using index; Not exists
[/编辑]
请帮忙
提前致谢