简体   繁体   中英

MYSQL Error, server has gone away?

i am useing the query below, when i run this query once per page there is no problem, but it needs to be called around 30+ times with slightly different values on a single page, sometimes it runs ok, sometimes the page never loads, and sometimes i get a "server has gone away" error, http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

is this a performance problem, do i need to break down this query into smaller ones (will that even have any effect), or is there something else i can do ?

SELECT normalmtm.id, normalmtm.amt, normalmtm.lockexpire, ptassumptions.id, ptassumptions.zero, ptassumptions.beta, ptdata.id, ptdata.date
FROM normalmtm
INNER JOIN ptdata ON ptdata.date = normalmtm.lockdate
INNER JOIN program ON program.clientcode = '1' AND program.clientprogram = normalmtm.program AND program.normalprogram = 'program'
INNER JOIN ptassumptions ON ptassumptions.clientcode = '1' AND ptassumptions.program = program.normalprogram
INNER JOIN purpose ON purpose.clientcode = '1' AND purpose.clientpurpose = normalmtm.purpose AND purpose.normalpurpose = ptassumptions.purpose
INNER JOIN status ON status.clientcode = '1' AND status.clientstatus = normalmtm.stage AND status.normalstatus = ptassumptions.status
WHERE normalmtm.clientcode = '1'
GROUP BY normalmtm.id

the normalmtm table has a few thousand rows, and the other tables are smaller normalised tables with around 100 rows

EDIT

its a WAMP server running on a local windows machine, Apache Version :2.2.11, PHP Version :5.3.0, MySQL Version :5.1.36

Do you have the proper indexes. This query should run in a jiffy if you only got the number of records you mention.

Looks like you've already found the answer.

How long does it take between creating the connection and issuing the query to the DBMS? How long does it take between starting the query and getting the error message? What is the value for wait_timeout?

the normalmtm table has a few thousand rows, and the other tables are smaller normalised tables with around 100 rows

So assuming the database is normalized (with joins based on times!!!!?????) and the query written correctly, the query should process something between 0 and 1000 x 100 x 100 x 100 x 100 x 100 rows (the latter is a rather large number).

Sounds like you need to look at your indexes.

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