MySQL Forums
Forum List  »  Performance

Slow performance with this select query
Posted by: ICI MASA
Date: July 07, 2005 12:57AM

Hi,
I need to select from three tables and the end result i need to list a few records from one of the tables with the latest date!

this is my sql query:

SELECT STRAIGHT_JOIN tbPoint.Nname, tbPoint.Nidx, tbPoint.NID, tmpTb.Value, tmpTb.VtimeStamp
FROM tbScanList INNER JOIN tbPoint ON tbScanList.TID = tbPoint.TID INNER JOIN
(SELECT va.DID, va.NID, va.Value, va.vTimeStamp FROM tbValue va INNER JOIN
(SELECT NID, MAX(VtimeStamp) AS LastUpdate FROM tbValue GROUP BY NID) lu
ON (va.NID = lu.NID and va.VtimeStamp = lu.LastUpdate) ) AS tmpTb ON tbPoint.NID = tmpTb.NID
WHERE tbScanList.DID = 42 ORDER BY tbPoint.Nname

when we run this query we get a cpu load of nerly 90% so we might need a faster cpu but what I need to know is if this is the right way to do it or if we can optimize the query. The table that hold the records to display has about 150.000 rows now could be much 10 times that..

If anyone need mor info of the table structure let me know and I will post it here!

Best regards
Martin

Options: ReplyQuote


Subject
Views
Written By
Posted
Slow performance with this select query
2058
July 07, 2005 12:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.