我们可以进一步优化Oracle查询吗?

时间:2017-04-24 12:17:54

标签: sql oracle query-optimization

这个查询花了2.17秒的时间而没有。输出中的行数为128000.所有源表都有大约100k行。但是相同的查询有时会在生产时间内花费更多时间,这是系统运行缓慢的原因,如Oracle 5g中排名前5位的高度查询时间所示。我们可以进一步优化它吗?

注意:为Where和On条件中使用的所有列创建索引。还可以找到附件查询计划。

    SELECT (ROWNUM)ROWNUMBER, RES.* 
                  FROM         
                  (SELECT PIDS,        
                  FILENUM,
                  FILETYPE,
                  ATT,        
                  FILESTA,        
                  WSNAME,        
                  CMP5.CLT_NAME AS CLIENT,        
                  CLT_CODE,
                  CLTREF,
                  TMTYPE,
                  ASSOCNAME,
                  FFCOUNTRY,
                  APPLICATIONNO,
                  FF_APPLICATIONNO,
                  FILING_TRADEMARKTITLE,
                  FF_TRADEMARKTITLE,
                  QUERY_TRADEMARKTITLE,
                  CMP6.DOCNAME AS SEARCH_TRADEMARKTITLE,
                  CMP7.DOCUMENTNAME as FF_SEARCH_TRADEMARK,
                  CMP.CLASS AS CLASSES,        
                  CMP4.CLASS AS CLASSESFF,        
                  CMP2.NAME             AS PROPRIETER,        
                  CMP2.CODE             AS PROPRIETERCODE,
                  CMP5.CNTRY AS CNTRY,
                  CMP5.STATE AS STATE,
                  CMP5.CITY AS CITY         
                  FROM        
                  (SELECT EXT.PID         AS PIDS,            
                  EXT.FILE_NUMBER       AS FILENUM,
                  EXT.proceeding_assignmenttype       AS FILETYPE,
                  EXT.ATTORNEY          AS ATT,          
                  EXT.FILE_STATUS        AS FILESTA,            
                  CURRENTWS AS WSNAME,         
                  EXT.CLIENT_CODE       AS CLT_CODE,
                  EXT.client_ref       AS CLTREF,
                  EXT.FP_APP_TYPE       AS TMTYPE,
                  EXT.ff_nameofassociate       AS ASSOCNAME,
                  EXT.ff_nameofcountry       AS FFCOUNTRY,
                  EXT.filing_trademarkno   AS APPLICATIONNO,
                  EXT.ff_trademarknumber   AS FF_APPLICATIONNO,
                  EXT.FILING_TRADEMARK AS FILING_TRADEMARKTITLE,
                  EXT.FF_TRADMARK AS FF_TRADEMARKTITLE,
                  EXT.Q_TRADEMARK AS QUERY_TRADEMARKTITLE
                  FROM EXT_TRADEMARK EXT         
                  WHERE CURRENTWSSTATUS = '1'      
                  ORDER BY EXT.FILE_NUMBER DESC
                  )EXTTABLE         
                  LEFT JOIN COMPLEX_TM_CLASS CMP         
                  ON EXTTABLE.PIDS = CMP.PROCESSINSTANCEID                           
                  LEFT JOIN COMPLEX_TM_PROPRIEATOR CMP2         
                  ON EXTTABLE.PIDS = CMP2.PROCESSINSTANCEID     
                  LEFT JOIN COMPLEX_TM_FF_CLASS CMP4         
                  ON EXTTABLE.PIDS = CMP4.PROCESSINSTANCEID         
                  LEFT JOIN FA_CLT_MSTR CMP5
                  ON EXTTABLE.CLT_CODE = CMP5.CLT_COD
                  LEFT JOIN COMPLEX_TM_SEARCH CMP6         
                  ON EXTTABLE.PIDS = CMP6.PID
                  LEFT JOIN COMPLEX_TM_FF_SEARCH CMP7         
                  ON EXTTABLE.PIDS = CMP7.PID order by FILENUM desc
                  ) RES ;

enter image description here enter image description here

0 个答案:

没有答案