6 Ответы Последний ответ: 13.02.2019 0:30, автор: knowledgespring

    hierarchical query in oracle database 12.2

    knowledgespring

      there are  managers, workers records in a table in which worker can work for more than one manager. the worker becomes manager for other workers, in turn they become manager for other worker and so on and on.. worker can work for more than one manager directly.

       

      below is the query to know who all workers worked for mgr_id 100 in overall. query takes almost 15 hrs plus to get the results.. can someone please help to get this query execution done faster.. table has just 1200 records.

       

      select DISTINCT worker_id from mgr_worker_link p start with  mgr_id=100 connect by PRIOR worker_id=mgr_id;

       

      SQL>  select * from  mgr_worker_link p  where  mgr_id=100;

          mgr_id worker_id 

      ---------- ------------- 

        100      183 

        100      985 

        100      537 

       

      -- to see who all worked for 183

      SQL>  select * from  mgr_worker_link p  where  mgr_id=183;

          mgr_id worker_id 

      ---------- ------------- 

        183      985 

        183      530 

       

      -- to see who all worked for 985

      SQL>  select * from  mgr_worker_link p  where  mgr_id=985;

          mgr_id worker_id 

      ---------- ------------- 

        985      530 

       

      worker 530 just not worked for 985 directly, but also worked directly for 183 whereas 985 also worked for 183 directly.

      and so on and on...many more..

       

      unique constraint on both mgr_id, worker_id.

       

      SQL Plan Monitoring Details (Plan Hash Value=xxxxx)

      ================================================================================================================================================================

      | Id   |                  Operation                  |    Name     |  Rows   | Cost |   Time    | Start  | Execs |   Rows   | Mem | Activity | Activity Detail |

      |      |                                             |             | (Estim) |      | Active(s) | Active |       | (Actual) |     |   (%)    |   (# samples)   |

      ================================================================================================================================================================

      | -> 0 | SELECT STATEMENT                            |             |         |      |       255 |     +6 |     1 |        0 |   . |          |                 |

      | -> 1 |   HASH UNIQUE                               |             |       1 |    2 |       255 |     +6 |     1 |        0 | 1MB |     8.08 | Cpu (21)        |

      | -> 2 |    CONNECT BY NO FILTERING WITH SW (UNIQUE) |             |         |      |       260 |     +1 |     1 |     530M |   . |    91.92 | Cpu (239)       |

      |    3 |     INDEX FULL SCAN                         | PK_MGR      |       1 |    1 |         1 |     +6 |     1 |      767 |   . |          |                 |

      ================================================================================================================================================================

        • 1. Re: hierarchical query in oracle database 12.2
          John Thorton

          How can we reproduce hat you report?

           

          Please click on URL below & provide requested details

           

          How do I ask a question on the forums?
          How to  improve the performance of my query? / My query is running slow.

          • 2. Re: hierarchical query in oracle database 12.2
            knowledgespring

            Sorry .. I could not find any other way to send these...

            Query:  select DISTINCT worker_id from mgr_worker_link p start with  mgr_id=100 connect by nocycle  PRIOR worker_id=mgr_id;

             

             

            Drop table MGR_WORKER_LINK purge;

             

             

              CREATE TABLE MGR_WORKER_LINK

               ( MGR_ID NUMBER NOT NULL ENABLE,

            WORKER_ID NUMBER  ,

            CONSTRAINT PK_MGR UNIQUE (MGR_ID, WORKER_ID)

               ) ;

             

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('924',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('538',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('574',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','924');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','538');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('115','954');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('866','283');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('866','030');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('866','958');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('780','115');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('930','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('930','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('930','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('930','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('930',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('654','574');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('936','115');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('083','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('083','530');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('209','115');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('149','780');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('149','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('920','115');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','936');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','504');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','642');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','995');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('336','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('406',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('334',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('985','530');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','936');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','504');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','642');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('994','995');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('885','115');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('609','115');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('888','936');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('888','209');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('888','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('888','920');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('888','609');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('413',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('644',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('530','888');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('892','530');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('537','209');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('537','920');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('537','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('351','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('504','083');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('504','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('504','537');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('642','083');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('642','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('642','537');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('894',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('411','892');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('273','083');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('273','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('273','537');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','083');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','537');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('210','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('995','530');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('065',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('308','642');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('308','995');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('668',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','936');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','504');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','642');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('854','995');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','490');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','406');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','994');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','210');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','087');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('016','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('185',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','936');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','504');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','642');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('764','995');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('325','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('617','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('283','765');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('283','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('283','308');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('283','854');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('283','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('283','538');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','936');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','885');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','504');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','642');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('651','995');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('538','892');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('538','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('207','866');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('207','411');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('207','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('207','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('555',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('030','765');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('030','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('030','308');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('030','854');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('030','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('030','538');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578','765');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578','308');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578','854');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('578','538');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('708','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('201','283');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('201','030');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('201','958');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('958','765');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('958','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('958','308');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('958','854');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('958','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('958','538');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('430','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('430','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('430','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('430','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('830','866');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('830','411');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('830','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('830','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('935',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('601','866');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('601','411');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('601','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('601','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','866');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','411');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('557','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('753','617');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('957',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','490');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','406');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','994');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','210');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','087');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('493','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('939','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('939','830');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('939','601');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('939','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('010',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('839','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('839','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('839','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('839','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('927','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('695',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('105',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('528','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('528',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('766','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('766','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('997',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('278','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('278','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('278','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('278','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('941','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('941','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('941','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('941','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('007','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('007','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('007','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('007','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('000',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('152','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('152','935');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('152','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('152','766');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('332','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('332','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('332','139');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('372','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('032',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('459','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('485','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('485','278');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('255','939');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('255','278');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('761','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('675',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('520','364');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('196',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('369','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('369','930');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('369','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('369','007');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('369','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('164','866');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('087',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('478','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('514','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('378','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('378','930');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('378','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('378','007');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('378','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('544',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','930');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','007');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('256',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('139','941');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('139','007');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('139','152');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('905',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('256','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('554','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('554','478');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('554','825');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('554','755');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('554','696');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('291','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('291','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('291','139');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('174','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('242','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('293','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('555','308');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('808','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('405','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('716','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','651');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','708');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','485');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('364','291');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('762','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('762','538');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('944',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('611','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('611','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('611','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('611','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('611','364');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('352','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('586','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('444',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('259',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('664','209');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('880','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('480','490');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('480','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('480','397');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('557','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('852','537');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('228','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('228','664');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('228','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('228','696');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('991','185');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','490');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','406');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','994');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','210');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','087');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('825','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('328',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','490');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','406');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','994');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','210');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','369');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','087');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('755','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('696','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('696','242');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('696','293');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('696','405');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('696','364');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('959','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','644');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','997');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','480');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','597');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','357');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','243');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('708','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('255',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','016');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','554');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','611');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','228');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','917');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('001','165');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('257','504');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('257','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('917','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('917','664');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('917','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('917','696');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','016');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','554');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','611');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','228');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','917');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('714','165');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('594','493');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('594','364');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('594','825');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('594','755');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('772','413');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','644');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','997');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','332');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','480');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','597');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','357');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','243');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('758','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('597','351');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('597','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('597','554');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('829',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('864','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('246','351');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('246','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('246','554');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('329','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('238','007');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('357','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('449','924');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('449','578');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('376','755');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('376','959');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('165','914');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','351');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('397','554');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('947',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('295','255');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('638','016');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('008',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('197','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('864',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('037',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('243',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('711',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('860',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('615','001');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('615','714');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('116','174');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('116','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('232','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('232','714');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('232','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('232','597');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('202','985');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('620','634');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('620','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('670',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('433','917');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('862','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('862','714');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('862','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('862','597');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('382','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('382','714');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('382','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('382','597');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('126','164');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('126','397');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('126','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('126','222');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('790','493');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('790','755');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('790','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('307','444');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('634','207');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('634','714');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('634','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('634','597');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('521','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('521','354');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('354','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('640','493');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('640','755');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('640','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('521','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('674','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('434','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','372');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','378');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','557');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','594');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','246');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('658','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('201','808');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('201','001');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('546','149');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('149',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('727',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('772','615');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('848','174');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('848','555');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('848','634');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('848','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('222','228');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('222','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('331','864');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('367','762');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('257',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','514');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','480');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','959');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','357');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','634');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','640');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('893','772');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('454','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('454','959');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('454','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('208','780');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('101','273');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('101','727');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('650','880');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('650','165');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('650','674');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('650','658');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','514');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','480');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','959');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','357');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','634');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','640');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('432','772');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('779','164');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('779','397');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('779','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('779','222');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('353','880');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('353','165');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('353','674');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('353','658');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','514');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','480');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','959');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','357');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','634');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','640');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('043','772');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('265',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('151','620');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('151','848');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('151','893');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('151','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','514');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','480');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','959');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','357');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','232');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','862');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','634');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','640');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','201');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('486','772');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('960',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','830');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','880');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','126');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','674');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','893');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','779');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','353');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','043');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('517','582');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('190','151');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('308','376');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('308','521');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('151','764');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('226','830');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('226','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('350','586');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('350','376');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('350','202');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('350','790');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('350','954');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('350','269');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','830');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','880');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','126');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','674');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','893');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','779');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','353');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','043');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('128','582');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('582','190');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('281','331');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','830');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','880');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','126');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','674');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','893');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','779');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','353');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','043');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('412','582');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('741','830');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('741','520');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('392','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('392','779');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('392','353');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('392','043');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('392','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('392','582');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','174');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','043');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','128');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','412');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('100','392');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('157','454');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('256','650');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('256','412');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('918','174');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('918','432');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('918','043');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('918','486');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','128');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','741');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','392');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','918');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('954','891');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('813',null);

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','650');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','517');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','226');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','128');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','741');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','392');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','918');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('269','891');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('690','586');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('690','376');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('690','202');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('690','790');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('690','954');

            Insert into MGR_WORKER_LINK (MGR_ID,WORKER_ID) values ('690','269');

            commit;

            • 3. Re: hierarchical query in oracle database 12.2
              AndrewSayer

              and so on and on...many more..”

              That turns out to be about 530 million rows and counting! Does that sound right to you?

               

              My first guess is that you are going through the same worker_ids multiple times causing your result set to snowball out of control.

               

              A similar problem came up recently and I think it turned out to be easier to write a PL/SQL block (probably a pipelined function) that iterates through the rows manually but removes duplicates as it goes.

               

              Others May have better ideas.

               

               

              • 4. Re: hierarchical query in oracle database 12.2
                knowledgespring

                at the moment, we consider only those ids given in insert statements.

                we no need to go through same worker_ids second time as it is already counted. and need to show only worker ids that worked for mgr_id=100;

                 

                Query:  select DISTINCT worker_id from mgr_worker_link p start with  mgr_id=100 connect by nocycle  PRIOR worker_id=mgr_id;

                 

                we included NOCYCLE clause that tells the database not to traverse cyclical hierarchies.

                • 5. Re: hierarchical query in oracle database 12.2
                  AndrewSayer

                  knowledgespring wrote:

                   

                  at the moment, we consider only those ids given in insert statements.

                  we no need to go through same worker_ids second time as it is already counted. and need to show only worker ids that worked for mgr_id=100;

                   

                  Query: select DISTINCT worker_id from mgr_worker_link p start with mgr_id=100 connect by nocycle PRIOR worker_id=mgr_id;

                   

                  we included NOCYCLE clause that tells the database not to traverse cyclical hierarchies.

                  As I said, you are going through the same worker_id values multiple times. Your distinct can not operate until the connect by has been fully evaluated.

                   

                  It's difficult for Oracle to determine when a cycle is hit by the connect by - judging by the amount of rows your connect by has found, it's not realizing it soon enough.

                   

                  This is why I suggested writing the logic using PL/SQL procedurally, that will give you much greater control

                  • 6. Re: hierarchical query in oracle database 12.2
                    knowledgespring

                    Can you please share the PL/SQL block that you talked about that iterates through the rows manually but removes duplicates as it goes and i think same plsql gives all the workers worked for mgr either via directly or indirectly..