-1
- 預需要幫助優化下面查詢
WITH pims AS
(
SELECT code, value
FROM T_QNT_EXT_INFO_TITRES
WHERE filter = 'PIMS'
AND key = 'INSTRUMENT'
),
generic_param_value as
(
select value
from T_OPS_GENERIC_PARAM
where process='PIMSREC'
and field in('HBEU_ISSU_INC','HBEU_INV_INC',
'HBEU_TRADE_INC', 'HBAP_TRADE_INC')
)
select t.sicovam, pims.value ,t.devisectt
from titres t,
AUDIT_MVT a,
histomvts h,
pims
WHERE t.sicovam = pims.code
and pims.value is not null
and t.affectation not in (4, 12)
and t.type not in ('A','F','E','M')
and t.sicovam IN (SELECT DISTINCT nvl(h.sicovam, a.sicovam)
FROM AUDIT_MVT a, histomvts h
WHERE a.refcon=h.refcon(+)
AND a.DATEMODIF >= (SELECT MAX(MARKER_DATE)
FROM REMOTE_SECURITY.MARKERS
WHERE MARKER LIKE '%_SOPUS.%'
AND MARKER_DATE < TO_DATE('&2 10:00','YYYYMMDD HH:MI'))
AND a.DATEMODIF < (SELECT NVL(MIN(MARKER_DATE),SYSDATE) FROM REMOTE_SECURITY.MARKERS WHERE MARKER LIKE '%_SOPUS.%' AND MARKER_DATE > TO_DATE('&2 10:00','YYYYMMDD HH24:MI'))
AND EXISTS (select 1 from business_events b where decode(a.version,1,h.type,a.type)=b.id and (b.compta in (0,1) or b.id=15))
AND coalesce(a.hsbc_opcvm_upd, 0) <> 1 --mark a trade's modification if it's Drag and Drop
AND decode(a.version,1,h.typesico,a.typesico) NOT IN (4)
AND exists (SELECT 1 FROM FOLIO, generic_param_value where ident=decode(a.state, 3, a.opcvm, h.opcvm) START WITH IDENT =generic_param_value.value
CONNECT BY PRIOR IDENT = MGR)
)
and not exists (SELECT 1 FROM T_QNT_EXT_INFO_TITRES t2 WHERE t2.CODE = t.sicovam
and t2.filter = 'PIMS'
and t2.KEY = 'TYPE'
and t2.VALUE in ('DPT', 'DFD/LBK')
)
and (((pims.value like 'P%')
and
((t.affectation <>5)
OR
(t.affectation=5 and (exists(select 1 from histomvts where contrepartie= 10019816 and sicovam=t.sicovam) OR lower(t.libelle) LIKE '%fees linked to p%'))
)
)
OR
(pims.value not like 'P%')
);
人們很難幫助你,因爲首先你需要訪問測試模式,其次是我認爲這是一個糟糕的問題。 –
我試着格式化你的查詢了一下。如果你可以讓其餘部分合理可讀,這將有所幫助。告訴我們查詢計劃是什麼。告訴我們存在哪些指標。告訴我們需要多長時間才能運行。告訴我們你的目標是什麼。告訴我們這些桌子有多大。告訴我們哪些謂詞是有選擇性的。現在,任何人都無法猜測什麼可能會很慢。 –