我有15個查詢爲報表的目的動態生成頁面上的表的數據。每個查詢需要250到900毫秒,這意味着根據服務器負載,頁面加載時間爲4到13秒。加載時間導致一些用戶認爲該頁面根本不會加載。如何提高ColdFusion MySQL的查詢時間?
我想知道是否有某種方法可以簡化查詢以提供更可接受的加載時間。這裏是其中一個查詢:
<cfquery datasource="MeetingDB" name="One">
SELECT COUNT(meetingID) AS countatron
FROM case_meeting
WHERE meetingID
IN (
SELECT DISTINCT a.meetingID
FROM case_meeting a
INNER JOIN meeting b ON a.meetingID = b.meetingID
WHERE b.categoryID = '1'
AND SUBSTRING(meetingCode, 5, 2)
BETWEEN 12
AND 22
AND SUBSTRING(meetingCode, 7, 2)
BETWEEN 01
AND 12
AND SUBSTRING(meetingCode, 9, 2)
BETWEEN 01
AND 31
)
AND caseID
IN (
'1', '2', '3', '28', '29', '30', '39', '40', '45'
)
GROUP BY meetingID
HAVING COUNT(caseID) > 0 AND COUNT(caseID) < 2
</cfquery>
<td><cfoutput> #One.recordcount# </cfoutput></td>
嗨,這是拋出錯誤。只有一個表名爲case_meeting – blarg 2013-02-25 09:45:21
PL您能否發佈錯誤 – Meherzad 2013-02-25 09:45:55
您的SQL語法中有錯誤; ('1','2','3','28','29','30','')檢查與您的MySQL服務器版本對應的手冊, 3'在第14行 – blarg 2013-02-25 09:50:57