Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! - Left Joins taking a long time to execute.

Status
Not open for further replies.

Spijker

Programmer
Jan 9, 2001
10
NZ
Hi

Can anyone help me with this problem.

Whenever I create a query with a number of left joins they can take up to 30 seconds to run on a web based MySQL database running through Apache.

The latest query to cause me grief is shown below:

SELECT DISTINCT equip.*,CONCAT_WS(' ',firstname,lastname)as name,rooms.rmdesc FROM equip LEFT JOIN stfeqlink ON stfeqlink.equipid = equip.autoid AND stfeqlink.datereturned IS NULL LEFT JOIN staff ON stfeqlink.staffid = staff.id AND stfeqlink.datereturned IS NULL LEFT JOIN rooms ON rooms.rmid = stfeqlink.room GROUP BY equip.autoid DESC ORDER BY equip.autoid;

The query works fine in that I get the result I want but it is taking way to long to give me the result.

Any help at all would be REALLY appreciated.
 
Sorry to say: I made the experience, that statements with DISTINCT take a lot (!) of time.
Try it without and look at the time response.

Hope it helps a little bit,

Roland

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top