Hit a slow SQL exception from the implementation plan view, and take the normal index, after further analysis:
the original SQL statement:
SELECT ROWNUM AS ROWNUMBER__,T.*
FROM (Select T1.ID AS "InvMainID",
T2.CONSIGNCODE AS "ConsignCode",
T2.ORDERCODE AS "OrderCode",
T3.CREATETIME AS "CreateTime",
T2.CUSCODE AS "CusCode",
T2.BILLDATE AS "OutTime",
T4.ISCANCEL AS "IsCancel",
T1.ISPRINT AS "IsPrint",
T3.TITLE AS "Title",
T3.ACCEPTER AS "Accepter",
T3.POSTCODE AS "PostCode",
T2.INVAMT AS "InvAmt",
T3.INVCONTENT AS "InvContent",
T1.PRINTOR AS "HandleMan",
T4.ISRED AS "IsRed",
T4.INVNO AS "InvNo",
T4.INVCODE AS "InvCode",
T1.PRINTTIME AS "PrintTime",
T2.INVAMT AS "ConsignAmt",
T3.ADDRESS AS "Address",
T2.ORGCODE AS "OrgCode"
From mbs7_inv.INV_CONSIGN T2
Join mbs7_inv.INV_INVORDER T3
on T2.ORDERCODE = T3.ORDERCODE
Join mbs7_inv.WL_PSINFO T5
on T2.CONSIGNCODE = T5.CONSIGNCODE
left Join mbs7_inv.Inv_InvMain T1
on T2.CONSIGNCODE = T1.CONSIGNCODE
left Join mbs7_inv.Inv_Record T4
on T1.ID = T4.InvMainID
Where ((((T2.INVAMT >= 1) And (T2.ISCANCEL = 0)) And
(T3.STATUS = 0)) And (T5.PSRESULT = 1))
ORDER BY T4.INVNO ASC, T1.ISPRINT DESC) T
WHERE T4."InvCode" = '144011320565'
AND T4."InvNo" >= '00011109'
AND T4."InvNo" <= '00011163'
AND ROWNUM <= 100
Implementation plan are as follows:
Here is the main part to achieve a red implicit conversion connection, and cause abnormal execution plan appears, COST increments great phenomenon:
the first performance is very slow, 1-2 minutes before the results came out, the application time-outs, and after performing a second faster, it can be 5 seconds.
Analysis:
try to create an index to accept sql_profile way optimized, but the effect is not obvious, the first execution of still very slow;
later found the execution plan for the statement consume a larger portion of the cost of such implicit conversion exists SYS_OP_C2C comparison, then
found table T1 and T2 are connected to the field and NVARCHAR2 varchar2, since the circulation through an implicit conversion, in this case
the final COST large, and the second performance, since the converted value already exists in the SGA, i.e., so a direct comparison available, the rate
quickly, in order to prove this point, after then refresh the SGA, to reproduce the problem immediately.
Solution:
Create an index, and the table T1 connection field into varchar2, implicit conversion implementation plan disappeared, COST significant decline in the first
execution within 3 seconds, the second time within 2 seconds after the execution, cost decreased from 100 to over 20,000.
Embodiment Operation:
SQL> CREATE INDEX mbs7_inv.ix_code_PSRESULT on mbs7_inv.wl_psinfo(CONSIGNCODE,PSRESULT) tablespace inv_index;
SQL> drop index mbs7_inv.IX_WL_PSINFO_PSRESULT;
SQL> alter table mbs7_inv.INV_INVMAIN modify CONSIGNCODE VARCHAR2(20);
Table altered
The optimized execution plan:
After eliminating the implicit conversion here, plan to use the normal index connection, COST significant decline!
DBA cases more updates, follow us CSDN blog!
Https://topdbs.blog.csdn.net