問題描述;
1.表規模是 150萬行,每行18列。 執行查詢語句:
selectcount(DeviceId) from(select DeviceId, count(distinct SubdeviceMac) as MACnumfrom wide_table_all_row where TIMESTAMPP LIKE "%2017-10-13%" group by DeviceId HAVING MACnum >= 5 and MACnum <= 10) as tmp;
報Error Code: 2013. Lost connectionto MySQL server during query。 每次都是等待30s報錯誤。
按照網上的經驗,修改mysql服務器的配置文件,my.ini的timeout時間,發現問題仍然存在。
後來換mysql安裝自帶的cmd命令行客戶端,沒有超時問題。 懷疑是mysql workbench 客戶端原因。
後來再MySQL workbench Q&A找到原因,鏈接如下 https://dev.mysql.com/doc/workbench/en/workbench-faq.html#faq-workbench-error-lost-connection
Yes, go to Preferences, SQL
Editor, and adjust the DBMS
connection read time out option
that defaults to 600 seconds. This sets the maximum amount of time (in seconds) that a query can take before MySQL Workbench disconnects from the MySQL server.
通過修改紅色字體的值,並重啓啓動workbench 生效(一定要重啓哦!)。