如何提高ColdFusion MySQL的查询时间?

bla*_*arg 3 mysql coldfusion query-timeout

我有15个查询,可以动态生成页面上的表数据以用于报告.每个查询需要250到900毫秒,这意味着页面加载时间为4到13秒,具体取决于服务器负载.加载时间导致一些用户认为页面根本不会加载.

我想知道是否有某种方法可以简化查询以提供更可接受的加载时间.以下是其中一个查询:

             <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>
Run Code Online (Sandbox Code Playgroud)

Meh*_*zad 5

试试这个查询

SELECT COUNT( a.meetingID ) AS countatron
          FROM case_meeting a, case_meeting b
          WHERE a.meetingID = b.meetingID 
          AND b.categoryID =  '1' 
          AND SUBSTRING( b.meetingCode, 5, 2 ) 
          BETWEEN 12 
          AND 22 
          AND SUBSTRING( b.meetingCode, 7, 2 ) 
          BETWEEN 01 
          AND 12 
          AND SUBSTRING( b.meetingCode, 9, 2 ) 
          BETWEEN 01 
          AND 31
          AND b.caseID
          IN (
          '1',  '2',  '3', '28',  '29',  '30', '39', '40', '45'
          )
          GROUP BY a.meetingID
          HAVING COUNT( a.caseID ) = 1
Run Code Online (Sandbox Code Playgroud)