How to tune a query which has decode?
Siva.VAug 24 2011 — edited Mar 8 2012Hi,
Iam a starter to PL/SQL performance tunning.pls help on to tune this query.
SELECT MIN (valutadatum)
FROM (SELECT buchung_id, buchungsgruppe, lfdnr, 0 stornomm,
SUM (betrag) betrag, SUM (mwstbetrag) mwstbetrag
FROM (SELECT DECODE (SIGN (NVL (d.erfass_refintern, -1)),
1, d.erfass_refintern,
DECODE (SIGN (NVL (d.erfass_ref, -1)),
1, d.erfass_ref,
d.buchung_id
)
) buchung_id,
d.buchungsgruppe, d.lfdnr, d.betrag, d.mwstbetrag
FROM historical d
WHERE ( ( d.fordnr = :b4
AND d.fordergnr = :b3
AND d.glaeubigernr = :b2
)
OR (d.mahnaktennr = :b1)
))
GROUP BY buchung_id, buchungsgruppe, lfdnr
HAVING SUM (betrag) != 0) a,
book b,
historical c
WHERE a.buchungsgruppe = b.buchungsgruppe
AND a.lfdnr = b.lfdnr
AND a.stornomm = b.stornomm
AND (NVL (b.nachmietvertrage, 0) = 1 OR NVL (b.sicherheitbezug, 0) = 1)
AND a.buchung_id = c.buchung_id
Execution Time:
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 54016 9.12 8.70 0 0 0 0
Fetch 54016 148.88 241.72 32275 7727019 0 54016
------- ------ -------- ---------- ---------- ---------- ---------- ---------- ................
total 108033 158.00 250.42 32275 7727019 0 54016