简体   繁体   中英

Lost connection to MySQL server during query

On MYSQL Workbench, I'm running this query : count(*) from test.nameTable I have couple millions rows in this table . after a while I get this error : Lost connection to MySQL server during query
I saw this question and its answers in other places but none of the answers helped.
I tried setting all timeout and packet size global variables to their maximum value, and spliting my query somehow.. But none of this methods worked.

SET GLOBAL connect_timeout=10000000
SET GLOBAL net_read_timeout=10000000
SET GLOBAL max_allowed_packet=1073741824

Anyone knows what could be the problem and how to solve it please?

If you are running from MySQL Workbench (as I can read on your comment, please update question), the program have their own timeouts.

If you go to the program menu, preferences -> SQL Editor, you have these options:

MySQL Session: DBMS connection keep-alive interval (in seconds): DBMS connection read time out (in seconds): DBMS connection time out (in seconds):

If you read descriptions from these options, you can see on the second one there's the time who workbench wait for a response from server.

If no row were ever deleted from the table, th primary key would describe the total count of rows, in which case you could probably try

SELECT MAX(pk) FROM test.nameTable

Not sure it would be faster, but maybe worth the try?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM