MySQL Forums :: Newbie :: Slow Query


Advanced Search

Slow Query
Posted by: Nick Price ()
Date: November 29, 2010 10:39AM

Hi Folks,

I'm new to SQL Queries,

The query below, obtains the latest record by Reading_Date for Device_Address 0 to 15. This worked fine, until I got a few thousand records, I've got 10,000 records now, and it takes approx 5 minutes to complete.

"SELECT SQL_BIG_RESULT
descriptors.Descriptor,
readings.Device_Address,
readings.Reading_Date as Reading_Date,
readings.Calibration_Date,
CASE WHEN readings.Low_Battery = 0 then 'FALSE' ELSE 'TRUE' END as Low_Battery,
CASE WHEN readings.Calibration_Over_Due = 0 then 'FALSE' ELSE 'TRUE' END as Calibration_Over_Due
FROM readings INNER JOIN descriptors ON readings.device_address = descriptors.device_address
WHERE readings.Reading_Date IN (SELECT MAX(readings.Reading_Date) FROM readings group by readings.Device_Address)
ORDER BY readings.Device_Address";

Any idea's on how to increase preformance.

Many thanks,

Nick

Options: ReplyQuote


Subject Written By Posted
Slow Query Nick Price 11/29/2010 10:39AM
Re: Slow Query Rick James 12/01/2010 01:05AM


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.