MySQL Forums
Forum List  »  General

How can I speed this query up?
Posted by: Kristy Atkins
Date: June 18, 2025 03:28PM

I just ran this query and it took 21 seconds.
Other short queries are almost instantaneous so it's not bandwidth.

The answers table is the largest table in the database having under 17,000 records total. This app is still in development not in operation yet.

RecordID, SurveyID and AttributionID are all indexed.
SolutionID, Table1ID and Table2ID make up a unique ID in the organization3_division3 table.


SELECT COUNT(DISTINCT surveys.RecordID)
FROM answers INNER JOIN surveys ON answers.SurveyID = surveys.RecordID
WHERE surveys.SolutionID = 3 AND surveys.RecordID IN
(SELECT SurveyID FROM answers WHERE AttributionID IN
(SELECT AttributionID FROM attrib_organization3_rl WHERE FieldID
IN (SELECT TABLE1ID FROM organization3_division3 WHERE TABLE2ID = 2)))
AND surveys.RecordID IN
(SELECT SurveyID FROM answers WHERE AttributionID IN
(SELECT AttributionID FROM attrib_forklift3_rl WHERE FieldID
IN (SELECT RecordID FROM forklift3 WHERE lnk_fuel_type = 1)))

Options: ReplyQuote


Subject
Written By
Posted
How can I speed this query up?
June 18, 2025 03:28PM


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.