When you use start with connect by nocycle prior
When performing recursive data search
So the performance of the following two sections of code must be significantly different when you use it, please note that the code can be directly read below to view my summary
// Query the number of layers in a folder ID = 12 and the number of files
A: indicates the parent-subordinate relationship between files.
B: The file in the folder.
Positive Solution:
Select count (0) cou, max (levels) + 1 as levels
Select C. a1, C. a2, C. levels...
From
(Select A. a1, A. a2 ,,,
Level levels // hierarchy
From
Where A. a1 = ,,,
And A. a2 = ....
Start with A. a1 = 12
Connect by nocylce prior A. ID = A. ParentID
) C left join B
On C. File ID = B. File ID
And C. file type = folder
Error code:
Select count (0) cou, max (levels) + 1 as levels
Select C. a1, C. a2, C. levels...
From
(Select A. a1, A. a2 ,,,
Level levels // hierarchy
From
Left join B
On C. File ID = B. File ID
Where C. file type = folder
And A. a1 = ,,,
And A. a2 = ....
Start with A. a1 = 12
Connect by nocylce prior A. ID = A. ParentID
) C
The difference between the above Code is that
The correct method is:
Recursively loop all the folders and files under a folder
Search for the file content in the associated file table
The error is:
First, find the folder and file under a folder.
Then recursively loop out all the folders and files in the folder below him.
In this way, the redundant data after Association is generated. Loop recursion is performed together. It has nothing to do with the file. Shouldn't it? The file is also put in recursion.