MySQL查询优化 - 多个INNER JOIN和WHERE子句

时间:2015-02-13 16:46:22

标签: mysql sql query-optimization inner-join where-clause

SELECT C.cellName,L.opcond,CR.value as CellRise,CF.value as CellFall,FP.value as FallPower, 
      RP.value as RisePower, CR.whend from CELLPROPERTYFACT F 
                        INNER JOIN LIBRARY L on L.libraryID = F.libraryID 
                        INNER JOIN CELL C on C.cellID = F.cellID 
                        INNER JOIN CELLRISETEMPLATE CR on CR.cellID = C.cellID 
                        INNER JOIN CELLFALLTEMPLATE CF on CF.cellID = C.cellID 
                        INNER JOIN RISEPOWERTEMPLATE RP on RP.cellID = C.cellID 
                        INNER JOIN FALLPOWERTEMPLATE FP on FP.cellID = C.cellID 
                        where C.cellName LIKE '%' 
                            AND FP.fromP = RP.fromP 
                            AND CR.fromP = CF.fromP 
                            AND RP.fromP = CR.fromP 
                            AND FP.fromP = CF.fromP 
                            AND FP.toP = RP.toP 
                            AND CR.toP = CF.toP 
                            AND RP.toP = CR.toP 
                            AND FP.toP = CF.toP 
                            AND CR.whend = RP.whend 
                            AND CF.whend = FP.whend 
                            AND CR.whend = FP.whend 
                            AND CF.whend = RP.whend 
                            AND CR.whend = CF.whend 
                            AND FP.whend = RP.whend 
                            AND RP.related_pin = FP.related_pin 
                            AND L.workWeek LIKE '%'
                            AND L.opcond LIKE '%'

如何优化查询?是否使用左连接比内连接更好,这样我可以在左连接中有多个ON语句?我的查询非常慢,需要2分钟左右才能完成

0 个答案:

没有答案