Home > database >  Frequent multi-table query result in poor performance, Montana and SQL to help analyze the place can
Frequent multi-table query result in poor performance, Montana and SQL to help analyze the place can

Time:10-01

SQL is as follows:
SELECT * FROM
(
The SELECT ROW_. *, ROWNUM ROWNUM_ FROM
(
SELECT
, dc F_NUM,
, dc F_ZXNO,
, dc F_GDSTA,
, dc F_CONTENT,
TO_CHAR (PI) START_, 'YYYY - MM - DD HH24: MI) AS FORM_START,
TO_CHAR (PI) END_, 'YYYY - MM - DD HH24: MI) AS FORM_END,
, dc F_GDTYPE,
(select sm_itname from sm_dict_item where sm_itkey=, dc F_BU2) as CF_BU2,
, dc F_ENDTIME,
Case
The when, dc F_GDSTA='B' OR, dc F_GDSTA='F' OR, dc F_GDSTA='C' THEN '0'
The when decode (PI) END_, null, sysdate, PI. The END_ + 0) & gt; TO_DATE (, dc F_ENDTIME, 'YYYY - MM - DD hh24: mi: ss')
Then to_char (decode (PI) END_, null, sysdate, PI. The END_ + 0) - TO_DATE (, dc F_ENDTIME, 'YYYY - MM - DD hh24: mi: ss'), 'fm999999990.09) else' 0 'end AS CF_OUTDATEDAY,
Case
The when, dc F_GDSTA='B' OR, dc F_GDSTA='F' OR, dc F_GDSTA='C' THEN 'OR'
The when decode (PI) END_, null, sysdate, PI. The END_ + 0) & gt; TO_DATE (, dc F_ENDTIME, 'YYYY - MM - DD hh24: mi: ss') then 'is' else' or 'end AS CF_ISOUTDATE,
, dc F_BANAME,
(select min (tr. Sm_time) from sm_trace tr where tr. Sm_fid=, dc F_ID and tr. Sm_dept='GS_GD0001' group by tr. Sm_dept)
AS cf_fd1,
(
The select sm_actor
The from sm_trace
Where sm_fid=, dc F_ID
And sm_time=(select min (tr. Sm_time) from sm_trace tr where tr. Sm_fid=, dc F_ID and tr. Sm_dept='GS_GD0001' group by tr. Sm_dept)
) AS cf_fd2,
(
The select min (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where
(
DECODE (org. Oflag, '1', '2', org. Oflag)='2'
The OR org. City_excode='GS_20001'
)
And tr. Sm_fid=, dc F_ID
And the tr sm_gdsta!
='A'And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND (org2. Parentcode IS NULL OR org2. Parentcode! )
='GS_KF0001') AS CF_FD3,
(
The select Max (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where
(
DECODE (org. Oflag, '1', '2', org. Oflag)='2'
The OR org. City_excode='GS_20001'
)
And tr. Sm_fid=, dc F_ID
And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND (org2. Parentcode IS NULL OR org2. Parentcode! )
='GS_KF0001') AS CF_FD4,
(
The select sm_actor from sm_trace
Where sm_fid=, dc F_ID
And sm_time=
(
The select Max (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where
(
DECODE (org. Oflag, '1', '2', org. Oflag)='2'
The OR org. City_excode='GS_20001'
)
And tr. Sm_fid=, dc F_ID
And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND (
Org2. Parentcode IS NULL
The OR org2 Parentcode!
='GS_KF0001')
)
) AS CF_FD5,
(
The select min (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where the tr. Sm_fid=, dc F_ID
And the tr sm_gdsta!
='A'And
(
Org. Oflag='3'
And org. City_excode!
='GS_20001')
And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND
(
Org2. Parentcode IS NULL
The OR org2 Parentcode!
='GS_KF0001')
Group by org. Oflag
) AS cf_fd6,
(
The select Max (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where the tr. Sm_fid=, dc F_ID and
(
Org. Oflag='3'
And org. City_excode!
='GS_20001')
And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND
(
Org2. Parentcode IS NULL
The OR org2 Parentcode!
='GS_KF0001')
Group by org. Oflag
) AS cf_fd7,
(
The select sm_actor from sm_trace
Where sm_fid=, dc F_ID
And sm_time=
(
The select Max (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where the tr. Sm_fid=, dc F_ID
And
(
Org. Oflag='3'
And org. City_excode!
='GS_20001')
And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND
(
Org2. Parentcode IS NULL
The OR org2 Parentcode!
='GS_KF0001')
Group by org. Oflag
)
) AS cf_fd8,
(
The select min (tr. Sm_time) from sm_trace tr
Left the join tb_sso_org org on org. Excode=tr. Sm_dept
Left the join tb_sso_org org2 on org2. Excode=org. Parentcode
Where the tr. Sm_fid=, dc F_ID
And the tr sm_gdsta!
='A'And
(
Org. Oflag='4'
And org. City_excode!
='GS_20001')
And org. Excode!
='GS_KF0001'And org. Parentcode!
='GS_KF0001'AND
(
Org2. Parentcode IS NULL
The OR org2 Parentcode!
='GS_KF0001')
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related