sql - How can I get the best Hierarchical Query performance in oracle -


i have table reply of structure following:

id   name   parent_id ...  1  reply1     0  2  reply2     1  3  reply3     2  4  reply4     3  5  reply5     4 

this table constructed on hierarchical relationship(sort of parent->child), how can sub replies according id of 1 replies? want use 1 sql accomplish best performance. because volume of replies huge , 1 tree have more 1000 rows.

i tried use start , connect by, came little poor performance.

appendix:

my rusty sql:

  select *      reply     start (parent_id=0 , id=?)   connect prior id=parent_id 

both id , parent_id being indexed, "connect by" statement seems expensive, , causes high cpu utilization on database side if multple "connect by" sql runs @ same time. example: 30 threads: takes 30 minuts on executing single query

without actual explain plan can guess.

i think index on parent_id not helping here since "trees" start root 0. make index composite -- ie: (parent_id, id). should speed start with clause, afterwards id index should used.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -