Home > Database > Mysql Tutorial > Oracle案例:通过添加本地分区索引提高SQL性能

Oracle案例:通过添加本地分区索引提高SQL性能

WBOY
Release: 2016-06-07 17:28:54
Original
1240 people have browsed it

今天接到同事求助,说有一个select query,在Oracle上要跑一分多钟,他希望能在5s内出结果,该sql如下: Select /*+ parallel(s

今天接到同事求助,说有一个select query,在Oracle上要跑一分多钟,,他希望能在5s内出结果,该sql如下:

Select  /*+ parallel(src, 8) */ distinct
  src.systemname as systemname
  ,  src.databasename as databasename
  ,  src.tablename as tablename
  ,  src.username as username
from  meta_dbql_table_usage_exp_hst src
 inner join DR_QRY_LOG_EXP_HST rl on
  src.acctstringdate = rl.acctstringdate
  and src.queryid = rl.queryid

  And Src.Systemname = Rl.Systemname
  and src.acctstringdate > sysdate - 30
  And Rl.Acctstringdate > Sysdate - 30
 inner join  meta_dr_qry_log_tgt_all_hst tgt on
  upper(tgt.systemname) = upper('MOZART')
  And Upper(tgt.Databasename) = Upper('GDW_TABLES')
  And Upper(tgt.Tablename) = Upper('SSA_SLNG_LSTG_MTRC_SD')
  AND src.acctstringdate = tgt.acctstringdate
  and rl.statement_id = tgt.statement_id

  and rl.systemname = tgt.systemname
  And Tgt.Acctstringdate > Sysdate - 30
  And Not(
    Upper(Tgt.Systemname)=Upper(src.systemname)
    And
    Upper(Tgt.Databasename) = Upper(Src.Databasename)
    And
    Upper(Tgt.Tablename) = Upper(Src.Tablename)
    )
  And  tgt.Systemname is not null
  And  tgt.Databasename Is Not Null
  And  tgt.tablename is not null
;

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template