Home » SQL & PL/SQL » SQL & PL/SQL » low performance of CONNECT BY (Oracle 11g)
low performance of CONNECT BY [message #653125] Tue, 28 June 2016 04:50 Go to next message
Elham_gh
Messages: 1
Registered: June 2016
Junior Member
Hi all
I have a serious problem.
First of all i wrote a view as:
SELECT            
                  Unit.ID                       UnitID,
                  Unit.parent                   ParentUnitID,
                  DocTyp.ID                     DocTypID,
                  DocTyp.RTDT_CODE              DocTypCode,
                  DocTypRel.RTDR_RTDT_REF_REL2  DocTypParent,
                  COUNT(Doc.ID)                 TotalDoc
FROM        
                  oc_unit         Unit
              INNER JOIN 
                  tb_rtdoc        Doc 
              ON  Doc.RTDC_DL_REF1=Unit.id
              LEFT OUTER JOIN
                  TB_RTDOCTYPE    DocTyp
              ON  DOC.RTDC_RTDT_REF=DocTyp.ID
              LEFT OUTER  JOIN  
                  TB_RTDOCTYPEREL   DocTypRel
              ON  DocTypRel.RTDR_RTDT_REF_REL1=DocTyp.ID
GROUP BY
                  ROLLUP(Unit.ID,
                  Unit.parent,
                  DocTyp.ID,
                  DocTyp.RTDT_CODE,
                  DocTypRel.RTDR_RTDT_REF_REL2)
              
ORDER BY          UnitID,
                  ParentUnitID,
                  DocTypID,
                  DocTypCode,
                  DocTypParent;

It works great. Then I wrote a query base on this view:
SELECT  
                  LEVEL, 
                  UnitID,
                  ParentUnitID,
                  DocTypID,
                  DocTypCode,
                  DocTypParent,
                  SUBSTR((SYS_CONNECT_BY_PATH ( UnitID ,'.')),2)  FullPath,
                  TotalDoc
          FROM    VW_Unit_Doc_DocTyp_Summary
          START WITH ParentUnitID IS NULL
          CONNECT BY PRIOR UnitID=ParentUnitID
But it works terrible! it takes more than 2 mins to exectue.
How can I improve my query performance?

Thanks alot
Re: low performance of CONNECT BY [message #653128 is a reply to message #653125] Tue, 28 June 2016 05:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Of course it depends on the number of rows but given the view text and the query, I think 2 minutes is a pretty good time.

For any performances question, please read http://www.orafaq.com/forum/mv/msg/84315/433888/102589/#msg_433888 and post the required information.

Re: low performance of CONNECT BY [message #653162 is a reply to message #653128] Tue, 28 June 2016 08:56 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
When you say it works great (the view). How long does it take to return EVERY row? A query can return the first rows fairly fast but when you are doing grouping in a view it has to process on EVERY row returned by the under laying select.
Previous Topic: SQL for Tables
Next Topic: Conversion Approach
Goto Forum:
  


Current Time: Fri Apr 19 08:37:41 CDT 2024