Start with in Oracle. How to optimize connect by prior

start with in Oracle. How to optimize connect by prior?
an address table has a total of 8-level addresses. Pass in the address id, to query all the superior addresses. The code is

.
select address_id    addressId,
           address_name  addressName,
           address_level addressLevel
          from rm_address t
             start with t.address_id = -sharpvillageId-sharp
            connect by t.address_id = PRIOR t.PARENT_ADDRESS_ID
             order by address_level
             
             

now the query is very slow, how to optimize it? -sharp-sharp title text-sharp-sharp

Jan.08,2022

for this kind of problem, it is recommended to talk about the amount of data in the table, the index, as well as the current execution time and execution plan of the sql statement, so as to facilitate everyone to analyze the problem.

according to the sql statement you wrote, please first check whether there is an index on the t.address_id field.

Menu