Hierarchy of the mother and father

Hi guys,.

I tried to write a query to return the genalogy a set ID.

We get the following configuration:

[Code]

create the genealogy of the table

(id varchar2 (10))

m_Id varchar2 (10),

F_ID varchar2 (10)

);

create an index only id_idx on genealogy (id);

create an index only m_id_idx on genealogy (m_id);

create an index only f_id_idx on genealogy (f_id);

insert into genealogy (id, m_id f_id) values (0,1,2);

insert into genealogy (id, m_id f_id) values (1,3,4);

insert into genealogy (id, m_id f_id) values (2,5,6);

insert into genealogy (id, m_id f_id) values (3,7,8);

insert into genealogy (id, m_id f_id) values (4,9,10);

insert into genealogy (id, m_id f_id) values (5,12,12);

insert into genealogy (id, m_id f_id) values (6,14,14);

insert into genealogy (id, m_id f_id) values (7,15,16);

insert into genealogy (id, m_id f_id) values (8,17,18);

insert into genealogy (id, m_id f_id) values (9,19,20);

insert into genealogy (id, m_id f_id) values (10,21,22);

insert into genealogy (id, m_id f_id) values (11,23,24);

insert into genealogy (id, m_id f_id) values (12,25,26);

insert into genealogy (id, m_id f_id) values (13,27,28);

insert into genealogy (id, m_id f_id) values (14,29,30);

insert into genealogy (id, m_id f_id) values (15, NULl, NULL);

insert into genealogy (id, m_id f_id) values (16, NULl, NULL);

insert into genealogy (id, m_id f_id) values (17, NULl, NULL);

insert into genealogy (id, m_id f_id) values (18, NULl, NULL);

insert into genealogy (id, m_id f_id) values (19, NULl, NULL);

insert into genealogy (id, m_id f_id) values (20, NULl, NULL);

insert into genealogy (id, m_id f_id) values (21, NULl, NULL);

insert into genealogy (id, m_id f_id) values (22, NULl, NULL);

insert into genealogy (id, m_id f_id) values (23, NULl, NULL);

insert into genealogy (id, m_id f_id) values (24, NULl, NULL);

insert into genealogy (id, m_id f_id) values (25, NULl, NULL);

insert into genealogy (id, m_id f_id) values (26, NULl, NULL);

insert into genealogy (id, m_id f_id) values (27, NULl, NULL);

insert into a values (id, m_id f_id) genealogy (28, NULl, NULL);

insert into genealogy (id, m_id f_id) values (29, NULl, NULL);

insert into genealogy (id, m_id f_id) values (30, NULl, NULL);

BEGIN

FOR I IN 31.50000 LOOP

INSERT INTO genealogy (id, m_id f_id) VALUES (I, NULL, NULL);

END LOOP;

END;

BEGIN

DBMS_STATS. GATHER_TABLE_STATS (OWNNAME = > USER,)

TABNAME = > "GENEALOGY."

METHOD_OPT = > ' for all indexed columns size auto ');

END;

SELECT ID, m_id F_id, LEVEL

GENEALOGY of level where < = 4

START WITH ID = '0'

CONNECT PRIOR M_ID = ID OR

PREREQUISITE F_ID = ID

[/ code]

I want that the members of the family up to grandparents.

The problem is that the execution plan uses a full table because of the OR condition scan. If I remove it uses unique ever access to a list.

but when I add the mother and father use a lot. I guess this SQL to access the table 15 times with access to the unique index. It would be much better than a FTS.

You have any ideas?

Thank you

You experience this problem is denormalized design. You can create the table of genealogy as:

drop table genealogy serving
/
create table (genealogy)
Identification number not null,
number of P_ID,
p_type varchar2 (1) not null
)
/
change the genealogy of the table
Add constraint genealogy_pk
(primary key)
ID,
p_type
)
/
change the genealogy of the table
Add constraint genealogy_chk1
Check)
p_type in ('F', ')
)
/
create indexes genealogy_idx1
about genealogy)
P_ID
)
/
Insert in the values(0,1,'M') genealogy;
Insert in the values(1,3,'M') genealogy;
Insert in the values(2,5,'M') genealogy;
Insert in the values(3,7,'M') genealogy;
Insert in the values(4,9,'M') genealogy;
Insert in the values(5,11,'M') genealogy;
Insert in the values(6,13,'M') genealogy;
Insert in the values(7,15,'M') genealogy;
Insert in the values(8,17,'M') genealogy;
Insert in the values(9,19,'M') genealogy;
Insert in the values(10,21,'M') genealogy;
Insert in the values(11,23,'M') genealogy;
Insert in the values(12,25,'M') genealogy;
Insert in the values(13,27,'M') genealogy;
Insert in the values(14,29,'M') genealogy;

Insert into values genealogy (0.2, 'F');
Insert into values genealogy (1.4, 'F');
Insert into values genealogy (2.6, 'F');
Insert into values genealogy (3.8, 'F');
Insert in the values(4,10,'F') genealogy;
Insert in the values(5,12,'F') genealogy;
Insert in the values(6,14,'F') genealogy;
Insert in the values(7,16,'F') genealogy;
Insert in the values(8,18,'F') genealogy;
Insert in the values(9,20,'F') genealogy;
Insert into values genealogy (10.22, 'F');
Insert into values genealogy (11,24, 'F');
Insert into values genealogy (12,26, 'F');
Insert into values genealogy (13,28, 'F');
Insert into values genealogy (14,30, 'F');

Insert into genealogy values (15, 'F', NULl);
Insert into values genealogy (16, NULl, 'F');
Insert into values genealogy (17, NULl, 'F');
Insert into genealogy values (18, 'F', NULl);
Insert into values genealogy (19, NULl, 'F');
Insert into genealogy values (20, 'F', NULl);
Insert into values genealogy (21, NULl, 'F');
Insert into values genealogy (22, NULl, 'F');
Insert into values genealogy (23, NULl, 'F');
Insert into values genealogy (24, NULl, 'F');
Insert into genealogy values (25, NULl, 'F');
Insert into values genealogy (26, NULl, 'F');
Insert into values genealogy (27, NULl, 'F');
Insert into values genealogy (28, NULl, 'F');
Insert into values genealogy (29, NULl, 'F');
Insert into genealogy values (30, 'F', NULl);
Insert in the values(15,NULl,'M') genealogy;
Insert in the values(16,NULl,'M') genealogy;
Insert in the values(17,NULl,'M') genealogy;
Insert in the values(18,NULl,'M') genealogy;
Insert in the values(19,NULl,'M') genealogy;
Insert in the values(20,NULl,'M') genealogy;
Insert in the values(21,NULl,'M') genealogy;
Insert in the values(22,NULl,'M') genealogy;
Insert in the values(23,NULl,'M') genealogy;
Insert in the values(24,NULl,'M') genealogy;
Insert in the values(25,NULl,'M') genealogy;
Insert in the values(26,NULl,'M') genealogy;
Insert in the values(27,NULl,'M') genealogy;
Insert in the values(28,NULl,'M') genealogy;
Insert in the values(29,NULl,'M') genealogy;
Insert in the values(30,NULl,'M') genealogy;
Commit
/
explain plan
for
Select eff.*,
level
Genealogy g
Start with id = 0
connection by p_id = prior id
and level<=>
/
Select *.
table (dbms_xplan.display)
/

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------
Hash value of plan: 2815987643

-----------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT |              |     6.   324.     6 (34) | 00:00:01 |
|*  1 |  CONNECT BY WITH FILTERING |              |       |       |            |          |
|   2.   TABLE ACCESS BY INDEX ROWID | GENEALOGY |     2.    56.     1 (0) | 00:00:01 |
|*  3 |    INDEX RANGE SCAN | GENEALOGY_PK |     2.       |     1 (0) | 00:00:01 |
|*  4 |   FILTER                       |              |       |       |            |          |
|   5.    NESTED LOOPS |              |     4.   164.     3 (0) | 00:00:01 |

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------
|   6.     CONNECT PUMP |              |       |       |            |          |
|   7.     TABLE ACCESS BY INDEX ROWID | GENEALOGY |     2.    56.     1 (0) | 00:00:01 |
|*  8 |      INDEX RANGE SCAN | GENEALOGY_PK |     2.       |     1 (0) | 00:00:01 |
-----------------------------------------------------------------------------------------------

Information of predicates (identified by the operation identity card):
---------------------------------------------------

1 - access ("ID" = "P_ID" PRIOR)
filter (LEVEL<>
3 - access ("ID" = 0)

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------
4 filter (LEVEL<>
8 - access("ID"="connect$_by$_pump$_002"."p_id préalable «)

Note
-----
-dynamic sample used for this survey (level = 2)

28 selected lines.

SQL >

SY.

Tags: Database

Similar Questions

  • connect and view the name of the mother and the child

    I have a table with ID, name, ParentID columns.  I have this request to show the ParentID. relationship ID.

    Select ParentID, ID from t1

    Connect prior ID = ParentID;

    Now, I want to get the name of the mother and child for each record.  The output would be ParentID | ParentName | ID | ChildName.  How I change the query to do this.  Thank you very much.

    I think that you he complicated:

    Select the id prerequisite parent_id,.

    parent_name previous name,

    ID child_id,

    name child_name

    from t1

    Start by parentid is null

    connect by parentid = prior id

    order by parent_id,

    child_id

    /

    PARENT_ID, CHILD_ID CHILD_NAME PARENT_NAME
    ---------- -------------------- ---------- -----------
    3 the King James 1
    3 4 Martin King
    5 Adams 2 Smith
    3 King
    5 Adams

    SQL >

    SY.

  • Create the hierarchy of the folders and multiple subfolders

    Dear friends,

    I copied the script to "create folder hierarchy" (created from chinna), but I need small change in their script, I added the below comment purposes created subfolder, its also created.

    But I need several folder created in the same hierarchy (see the screenshot "my requirement")

    var target is Folder.selectDialog ("choose a target folder");.

    If (!) ((Folder(target+"/"+"Folder A"))) .exists)

    {

    new folder (target + "/" + "PRODUCTION" + "/" + "APPL" + "/" + "DD-MM-YY") .create ();

    }

    OUTPUT:

    Screen Shot 2014-08-02 at 4.00.58 PM.png

    MY REQUIREMENT IS:

    Screen Shot 2014-08-02 at 4.00.49 PM.png

    Thanks in advance:

    Kanaga kumar. k

    Hi kanaga kumar,.

    There are several ways to do so. With the logic of the Cognet script, you can do something like this:

    var target = Folder.selectDialog("Choose a target folder");
    if(!(Folder(target+"/"+"PRODUKTION")).exists) {
        new Folder(target+"/"+"PRODUKTION").create();
        }
    if(!(Folder(target+"/"+"PRODUKTION"+"/"+"APPL")).exists) {
        new Folder(target+"/"+"PRODUKTION"+"/"+"APPL").create();
        }
    if(!(Folder(target+"/"+"PRODUKTION"+"/"+"FONTS")).exists) {
        new Folder(target+"/"+"PRODUKTION"+"/"+"FONTS").create();
        }
    if(!(Folder(target+"/"+"PRODUKTION"+"/"+"IMAGES")).exists) {
        new Folder(target+"/"+"PRODUKTION"+"/"+"IMAGES").create();
        }
    if(!(Folder(target+"/"+"PRODUKTION"+"/"+"PDF")).exists) {
        new Folder(target+"/"+"PRODUKTION"+"/"+"PDF").create();
        }
    

    Have fun

  • Benefits of the hierarchy of the position and hierarchy supervisor?

    Hello
    need to know which is sutable for the trust hierarchy? eaither supervisor or Position? Why? benefits and say benefits please?

    http://Oracle.ITtoolbox.com/groups/technical-functional/Oracle-Apps-l/purchasing-hierarchies-3598029
    See the link above

    Ralu

  • Add the hierarchy to the dash prompt

    Hello

    I have a question

    I created the analysis:

    And add filters:

    And I add the hierarchy of categories of purchases to prompt dashboard:

    But when I open a dashboard and choose an option in the command prompt, for example:

    Nothing happens:

    Do I need something additional set or If there is even an option use a hierarchy in command prompt ?

    Hello

    When to use a hierarchy as a guest you don't filter the analysis by setting "is invited" at all levels but you add the hierarchy in the analysis and using the stages of selection, you set it can be replace by the guest. "

  • IPhone flattened my mother fell and broke her screen and I bought a new Yvonne, but I want to know the iPhone ID forget him, I can send the IMEI or help me so that I change the iPhone to my mother and I thank you

    IPhone flattened my mother fell and broke her screen and I bought her a new iPhone, but I want to know the iPhone ID forget him, I can send the IMEI or help me so that I change the iPhone to my mother and I thank you

    Yvonne > > iphone

    Sorry

  • When I updated my iPhone 6 more iOS 9.3 my camera will not be to the point and seems blurred by far. I already reset my iPhone and my mother worked... Anything other ideas, might be a bug in the iOS update?

    When I updated my iPhone 6 more iOS 9.3 my camera will not be to the point and seems blurred by far. I already reset my iPhone and my mother worked... Anything other ideas, might be a bug in the iOS update?

    I would say "try and do a restore as new iPhone" like everyone else but I'm having a similar problem and nothing works! I've restored all the possible ways and nothing. I got my screen replaced and I still have the same home button but my phone updated with error 53 (makes the phone unusable) but the camera did work before the update. and Apple has released iOS 9.1.2 (13D 20) to correct the error 53 (mainly for other reasons) but when I go to use the camera, it is only black! If someone could help 'discovered' and I would be great!

  • Error 0X0000007E Stop after installing the new card mother and CPU.

    Original title: Stop error after installing the new card mother and CPU.

    After I installed a new motherboard and CPU I got a stop error 0X0000007E (0XC0000005, 0XB77EA756, 0XB84C742C, 0xB84C7128) and it restarted immediately. It always starts in safe mode, but I can't understand what is wrong. The old processor is a pentium 4 3 ghz, not sure what the motherboard was, new processor is AMD Athlon 64 X 2 Dual core 4200 + and I only know that the motherboard is an ASUS socket AM2. Device Manager does not recognize the CPU correctly, it shows just two entries called processor. As far as I can tell, it's almost certainly a driver issue, but I don't know how to diagnose or fix this. I am running windows XP home, I removed my video card, running 2 hard drives at 120 g (M) and 200 g (S), a DVD drive (M) and a reader of CD (S), and a stick of RAM to 1 GB.

    If you have made the change without having to reinstall XP, you will be taking and Pray H@ll. the best thing to do would be to reinstall XP and make sure you have the drivers available for your motherboard available so that you can update the installed chipset. In addition, be aware that if you have an OEM of Windows version, the license is dead when you changed the mother/CPU card.

    I hope this helps.

  • Help with the new card mother and Vista problem?

    So yes, I got a new card mother and cpu, it seems to work fine except the loading of windows! I said to reinstall vista, however, my computer never came with a vista CD, it was already installed. all I have is restoring 3 DVD. What I could find on the internet is a: A: I need to spend money for a BONE

    b: use linux

    work of the restore cd to reinstall the OS, so I can use my new motherboard?

    So yes, I got a new card mother and cpu, it seems to work fine except the loading of windows! I said to reinstall vista, however, my computer never came with a vista CD, it was already installed. all I have is restoring 3 DVD. What I could find on the internet is a: A: I need to spend money for a BONE

    b: use linux

    work of the restore cd to reinstall the OS, so I can use my new motherboard?

    Hey icuhavoc

    are recovery disks to reinstall vista with the original hardware installed if I understand you correctly know what records you need to know a set of manufacturer's recovery disks

    If it is pre-installed this is an oem license and does not change unless you did it in consultation with the manufacturer of models of motherboards and processors

    Walter, the time zone traveller

  • field default hierarchy is missing for the PO and the form of document types SPOin req

    Hi gurus,

    Please help me find the error in the implementation of the approval req.
    field default hierarchy is missing IN Req and standard purchase in the form of document type order.
    I checked the box 'use the hierarchy' on the human resources in the financial options tab.
    what I need to do any other configurations...

    Hello

    Please uncheck the 'Use approval hierarchy' flag and save the changes.
    Again, check the indicator of "Use trust hierarchy" and save the changes.

    Run the following query to check the value of the flag of the 'trust use hierarchy"for the problematic control unit.

    Please provide the id of operating as the query entry unit.
    Select USE_POSITIONS_FLAG from financials_system_params_all where org_id = '& org_id;

    It must return a value 'Y '.

    Now, log out of the application and log in again & check types of documents.

    Thank you
    Seddik

  • Change card mother HP Envy H8 - 1437C:-now the HP site doesn't recognize the computer and provide access to updates

    Replaced the motherboard with a new one of the same model and type - the work of the motherboard - but trying to get the Bios and the Board of Directors, updates of HP - model automated search HP software is unable to detect this new motherboard / computer - how to get this motherboard to be detected and updated via the HP website...? Note that it is just after the warranty period so I don't have phone support... the new motherboard works and is what I use now for this announcement...

    Bob, welcome to the forum.

    You will not be able to get updates of software or drivers to Win 10 of the HP Web site.  There is none is available.  Here is a guide that provides HP on this page.  Your best option is to run Windows Update to check updates are available.  Win 10 has built-in many pilots.

    Please click on the button + Thumbs up if I helped you and click on accept as Solution If your problem is resolved.

  • Hotmail 44 looks like your mother has not finished to set up parental controls for your account settings. Click "Access the parental control settings" to complete the process and access your account.

    I love how you get this error message, and then says that there is no support for this information.  You would think that if MS wrote this error message, they would assume someone would finally get it and need help.  Why I've bothered with this company I have no idea.

    All I want is to get my child HM account work. Ive clicked all this parental control I can find.  If this was the issue of the xbox, Id go immediately to gmail.

    Hello

    Had the same problem as the rest. All fixed now by:

    Abducted child security account for the family (Instructions in this thread)

    Account and went to outlook.com, let the updates.

    deleted the account from the local computer (Windows 8, users through the control panel * no * new user interface)

    Added and ensure that parental control is back on (it is by default)

    Can access the messages and followed the account. The account I had was old enough and not yet been used.

  • Hello, I get upgraded my computer and change the card mother and new CPU.__Is it no problem to install my OS. and re-activation. ???

    Activation

    If you have a retail version of XP, there will be no problem. A repair installation may or may not work. Of course you will be smart and save your data on an external first.

    If you have a version of XP OEM, it is related to the original computer on which it is installed. Since replacing the motherboard and processor you effectively create a new computer, you must purchase a new copy of XP in this case.

    http://www.michaelstevenstech.com/moving_xp.html - to change the motherboard
    http://www.michaelstevenstech.com/XPrepairinstall.htm - repair install how-to
    http://michaelstevenstech.com/cleanxpinstall.html - Clean install - how-to
    http://www.elephantboycomputers.com/page2.html#Reinstalling_Windows - what you will need at hand
    MS - MVP - Elephant Boy computers - don't panic!

  • Install a new hard drive and Windows 7 loading no settings are changed on the mother board or bios installation? :

    I have a desktop Dell-540 in which my c drive is a Raid 1 configuration of 1 TB (two disks to not up to 1 TB, Raid 0, which is the backup) which has all my programs and data.  I have a 2nd J: 1 TB (single drive - no raid) drive that I use as my back in-house to my drive c.

    I am running in all genres or the problems of Windows 7 as well as running out of space so I would install a new 2 TB drive as new drive c and re - install windows 7 for a clean install on a single partition.  I intend to disconnect my current c drive (which consists of my two disks in a raid 1 configuration) as well as to disconnect the 1 TB drive unique j and connect my new 2 TB drive.  I would like to install a clean version of windows 7.  So my question is this:

    If I disconnect all the old disks (c and J) and install a new one and start to load windows 7 on it, the new facility does affect the bios or motherboard settings?

    f for some reason so I have encounter problems, can I just unplug my new drive of 2 TB and re - connect my original c drive and drive j back to the motherboard and have it load up as it was before original, I unplugged my old PC would be back up and runing?  Or, install Windows 7 on a new drive change the settings of the motherboard or bios Setup that would prevent me to connect to any return to as it was before I started?

    In fact, raid 0 is striated, which means that two readers work as something one 1 TB raid 0 disk is made from two 500 GB drives. RAID 1 is mirrored, meaning that you would have two 1 TB drives each of which is one exact copy of the other. Replacing your hard drive and perform a clean installation of Windows 7 will not change your bios settings. You will need to enter the bios and change the configuration of the training of raid 0 or 1 for sata before install Windows on the new drive. To return to your original configuration and the hard disks, you will need to enter the bios and re - configure the hard drives in the raid 0 array or 1, whatever one you had.

    Jim

  • How to set the brightness and contrast for HP Omni 120-1125.

    You will have to troubleshoot my mother-in-law who has a HP Omni 120-1125.  Impossible to find info in the online books

    I don't know any button to change the display settings on this computer. However, I think I can help you find the equipment and audio in the control panel. I hope that all you need to do is change the setting "display by. I suspect that right now, it's on one of the icon views.

    Open the control panel and in the upper right, click the drop-down list next to "view in:

    Select "category".

    You should now see a list of categories, including equipment and audio.

    And now, I hope that the steps that I posted before will work for you. Please let me know if you encounter any problems.

Maybe you are looking for