Index unique creation implicit or explicit?

I read Steve O'hearn 1zo - 047 manual p.404 he mentions:

A unique index is the one who makes sure that a column in a table will contain unique

information. The syntax to create a unique index is:

CREATE A UNIQUE IX_EMP_SSN ON EMPLOYEES (SSN) INDEX;

This is different from the UNIQUE constraint that you can apply to a column on

a table. However, note that if you create a PRIMARY KEY or UNIQUE constraint

on a table, a unique index will be created automatically with the constraint.

Note that the UNIQUE constraint is more auto-documentent be in the database.

However, Oracle Corporation recommends that officially single

index to enforce the uniqueness in a column, for best results in the performance of the queries.

OK, so the area in bold has me a little confused.  Is it saying that the Unique constraint index are more oriented for thin self-documentation so that we should create the Unique Index explicitly?

Or is it simply that because the UK/PK document constraints because mentioning if it is recommended to create these constraints/index.

Sorry for what may seem like a vague question, I did have the chance to work on the optimization of the indexes, or I would be able to return effectively this task at this time, so I thought I would ask for advice on the forums...

Thank you.

It is difficult to comment on the intention of the author.

But note:

1. a unique constraint by default creates a unique index if a suitable index does not exist already.

2. a unique constraint can be monitored through a non-unique index if needed/wanted

3. a unique constraint or primary key is required if the creation of a foreign key.

4. If the index is created implicitly and you remove the constraint of the index is also deleted.

5. If the index is created explicitly and you remove the constraint of the index remains.

6. If you want a constraint can be delayed, then you will need a unique constraint and a non-unique index.

7. you can use a unique index with an expression to apply conditional oneness.

The constraint is certainly better than just a unique index self-documentation - I definitely see developer get confused when uniqueness is violated and that they get an error and they do not find a corresponding constraint.

Tags: Database

Similar Questions

  • sizes of compressed index (unique vs. non-unique)

    Hello

    I wonder if anyone can shed any light on what is happening internally in an index which explains the behavior I see when you do the compression tests. It's all about 11.2.0.3.8 on SLES11.

    I have a simple table with about 12 columns, the initial size is 48 GB, I have that compress with compression OLTP and it comes down to 18 GB - that everything is perfect

    The table has 4 clues in this respect everything I can rebuild with the option 'compress' (i.e. just old style compression - there is no advanced for the index compression) - and I see a strange behavior. I took just a hint an example here:

    It's the creation command to original index - which creates an index of 14 GB

    CREATE INDEXES 'RESET_INDEX' ON 'RESET' ('INS_NUM', 'PARAM_SEQ_NUM', 'PARAM_RESET_HEADER_SEQ_NUM', 'RESET_SEQ_NUM');

    If I run the present

    CREATE INDEXES 'RESET_INDEX' ON THE COMPRESS OF 'RESET' ('PARAM_SEQ_NUM', 'PARAM_RESET_HEADER_SEQ_NUM', 'INS_NUM', 'RESET_SEQ_NUM');

    In fact, the index grows - it becomes 18 GB (because of the many column values that are only 1 or 0 according to me that end by expands when compression is enabled)

    However - and this is the bit that confuses me

    CREATE AN INDEX UNIQUE 'RESET_INDEX' ON THE COMPRESS OF 'RESET' ('PARAM_SEQ_NUM', 'PARAM_RESET_HEADER_SEQ_NUM', 'INS_NUM', 'RESET_SEQ_NUM');

    By adding the 'unique' keyword, index is massively more small-, now only 8 GB!

    What is happening here - when an index is unique fact that somehow ID stored inside it must also be compressed where, in a non-unique index, this is not possible?

    Which seems very strange - but the question - if I add a surrogate key column to a table and add it to all my index finger and make it unique as all my index finger will then get more small when compressed...?

    See you soon,.

    Rich

    The response of a Word is not.

    The explanation lies in what happens in the article published in the 2 'compress' on the unique index producing an error.

    For an index not unique 'compress' with no count of column means 'compress n', where n is the number of columns in the index. for an index unique 'compress' means "compress n - 1".

    Your "change to single" index gets smaller on the compression, because it shows duplicates on the first 3 columns (of 4).

    Concerning

    Jonathan Lewis

  • Null implicit and explicit null

    Hi experts,

    I met two terms which is null implicit and explicit null and I were confused.

    anyone can try to explain what that means exactly by both of these terms.

    Implicit-null I understood - it's the last jump announce a lambel in 3 to indicate that it as implicit-null

    Please suggest

    Concerning

    Mahesh

    Hello

    Explicit and implicit null labels are generated by the router to the last jump to its neighbors.

    Implicit null is the default which means penultimate router must only send IP packet thus, it appears the label (the label known as PHP and it is done to reduce the load on the router of the last jump to burst). One of the drawbacks in implicit null approach is if the network is configured for QoS based on MPLS EXP bits, QoS is lost between the penultimate router and router the last jump.

    In this case, we can make use of Explicit null which means router penultimate jump does not jump label. It sends with the value of the label of 0 but with other areas including intact EXP bits. This way QoS treatment is kept between penultimate router and router the last jump. Explicit null value must be configured manually in the router of the last jump.

    HTH.

    Arun

  • Explain implicit and explicit curesor for example?

    Explain implicit and explicit curesor for example?

    Is less than the example of implicit cursor belogs?

    Set serverout
    Start
    I'm in (select * from emp)
    loop
    dbms_output.put_line (i.empno);
    end loop;
    end;

    All THE SQLs are analyzed and stored and runs under the cursor. These are stored in shared SQL database Pool.

    You can view the contents of the shared pool (and sliders inside it) using the V$ SQLAREA and other views of virtual performance.

    The concept of a cursor implicit and explicit cursor is a concept of LANGUAGE - not a SQL concept. It depends on how this language (client) (PL/SQL or Java or C/C++ or Delphi or c# and Perl, etc.) implements its interface language for SQL cursors created in Shared Pool data.

  • Ref Cursor on implicit and explicit cursors

    Hello

    In my company the drafting of PL/SQL procedure, everyone uses "Ref Cursor",
    But the article below, said implicit is the best, then Explicit and Ref Cursor...

    [http://www.oracle-base.com/forums/viewtopic.php?f=2 & t = 10720]

    I'm a bit confused by this, can someone help me understand this?

    Thank you

    SeshuGiri wrote:

    In my company the drafting of PL/SQL procedure, everyone uses "Ref Cursor",
    But the article below, said implicit is the best, then Explicit and Ref Cursor...

    [http://www.oracle-base.com/forums/viewtopic.php?f=2&t=10720]

    I'm a bit confused by this, can someone help me understand this?

    It has performance and it has performance...

    To explain. There is one type of cursor in Oracle - that is the cursor which is analyzed and compiled by the SQL engine and stored in the shared the database pool. The "+ client +" then receives a handle (called a SQL statement handle of many APIs) that can be used to make reference to this slider in the SQL engine.

    The performance of this slider is not determined by the customer. It is determined by the execution plan and how much enforcement of this slider cost ito of server resources.

    The customer can be Java, VB, .net - or a PL/SQL program. This client language (SQL client), has its own structures dealing with this from the SQL engine cursor handle.

    It can hide by the developer all together - so that they can't even see that there is a statement handle. That's what the implicit cursors in PL/SQL.

    It can allow the developer to manually define the structure of slider - this is what the explicit cursors, ref Cursor and DBMS_SQL cursors in PL/SQL.

    Each of these client cursor structures provides the programmer with a set of features to address different SQL cursor. Explicit cursor in PL/SQL constructs do not have the use of dynamic SQL statements. REF CURSOR and cursors DBMS_SQL do. REF CURSOR does not allow the programmer determine, at runtime, the structure of the projection of the cursor SQL. DBMS_SQL sliders do.

    Only ref Cursor can be created in PL/SQL and then handed over to another client (for example, Java/VB) for treatment. Etc.

    If each of the works of art/customer interfaces gives you a different feature for SQL cursors.

    Choose the implicit cursors for example does not the SQL cursor move faster. The SQL engine does not know and does not care, which customer construct you use to deal with the SQL cursor handle, he gave you. It does not matter. It does not affect his performance of cursor SQL.

    But on the client side, it can matter - if your code when dealing with that SQL cursor determines how fast your interaction with this SQL cursor is. How many context changes you make. How you use and reuse the SQL (for example hard vs soft analysis vs analysis reusing the same cursor handle). Etc.

    Are there any unique client cursor construction which is better? N °

    It's ignorant views. The customer's language provides a box tool, where each tool has a specific application. The competent developer will use the right tool for the job. The stupid developer will select a tool and use it as The Hammer to 'solve' all problems.

  • Implicit vs explicit cursor

    Hello

    I read somewhere that the implicit cursor is used in the sql statement only returns a single line and explicit cursor is used when the sql statement returns several lines.
    I did not understand it. Why is it so? Can we not use cursor name when Sql returns multiple lines or explicit only one line?
    can someone explain this for example.

    Thank you
    AB

    AB312062 wrote:

    I read somewhere that the implicit cursor is used in the sql statement only returns a single line and explicit cursor is used when the sql statement returns several lines.

    Fake.

    I did not understand it. Why is it so? Can we not use cursor name when Sql returns multiple lines or explicit only one line?
    can someone explain this for example.

    Explicit cursor - allows you to set the cursor "overall" (e.g. pakage body) and reuse them several times in different procedures/functions in this package.

    Explicit cursor - allows you to bulk explicit code collect and have direct access to the collection.

    Implicit cursor - neither of the above is true, but the implicit cursor still has bulk of collection in the scenes, requires less code instructions to create (and no need to explicitly close the cursor either).

    An implicit cursor might look as follows:

    declare
      type TObjectNames is table of varchar2(30);
      names TObjectNames;
      name varchar2(30);
    begin
      --// single row fetch
      select object_name into name from user_objects where object_id = 123;
    
      --// bulk fetch
      select object_name bulk collect into names
      from user_objects where object_type = 'TABLE'
      order by 1;
    
      --// for loop
      for c in (
        select object_name bulk collect into names
        from user_objects where object_type = 'TABLE'
        order by 1
      ) loop
        do something with row c
      end loop;
    end;
    
  • Unique creation TreeTable from two houses linking your

    Hello

    Lets say, I want to show the organizational structure in TreeTable in the following format

    NOTE: I'm sorry, I'm not able to get back. All ranks below layout is indent level compared to above the line

    Continent
    Country
    AreaHead
    Employees


    If the layout should look like

    ##############################################################
    Asia
    India
    Ahead01
    Emp01
    Emp02
    ##############################################################

    Here are the charts that I use

    1. LOCATION - Self linking table that shows continents and countries hierarchically.
    For example:
    | Location | Location_id | Parent_Location_ID |
    | The India | 100. 101 |
    | Asia-Pacific | 101 | 102.

    2. EMPLOYEE Table - Employee table that contains the details of the employee
    Its a car that connects the table that defines the Manager, team member relations
    Contains a foreign key to the LOCATION table

    | Employee_ID | Name | Designation | Location | Manager_ID |
    | 100. Emp01 | Head of sector | 100.
    | 101 | Emp02 | Head of Department | 100. 100.

    I created two your LOCATION, EMPLOYEE and two self referencing links
    one about the LOCATION. Location_id from LOCATION. PARENT_LOCATION_ID
    an employee. Employee_id to EMPLOYEE. MANAGER_ID

    While displaying a tree table details in the EMPLOYEE table should start from the COMMUNITIES table leaf node.

    Please let me know the best way to achieve this. I agree with creating a program to access the other your VO?

    I use JDeveloper: 11.1.1.3.0

    Published by: 817895 on December 5, 2010 06:06

    Published by: 817895 on December 5, 2010 06:13

    Hello

    see the example on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html 32

    Frank

  • Why B * TREE index does not work when ask explicit type conversion.

    What is the job of back-end of B * column indexed with numeric type data when to perform explicit Conversion in the WHERE clause of number of Char.

    Basically my question is why index does not work when applying both sides TO_CHAR conversion in where clause?

    Let's say we have a table with 1 million rows

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

    Create Table T (collar number);

    -The unique index on the column.

    CREATE A UNIQUE IDX_T ON T (CSA COL) INDEX.

    -Insert the statement on the table with million lines

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

    Begin

    For I In 1.1000000 loop

    Insert Into Values T (I);

    End loop;

    COMMIT;

    End;

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

    We have different situations using

    explain plan for select col from t where col =?;

    SELECT * FROM TABLE (DBMS_XPLAN. DISPLAY);

    Case 1.  Where COL = 50555;

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    0 | SELECT STATEMENT |       |     1.    13.     0 (0) | 00:00:01 |

    1.  INDEX UNIQUE SCAN | IDX_T |     1.    13.     0 (0) | 00:00:01 |

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

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

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

    1 - access ("COL" = 50555)

    Case 2.  Where COL = '50555';

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    0 | SELECT STATEMENT |       |     1.    13.     0 (0) | 00:00:01 |

    1.  INDEX UNIQUE SCAN | IDX_T |     1.    13.     0 (0) | 00:00:01 |

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

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

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

    1 - access ("COL" = 50555)

    Case 3.  Where TO_CHAR (COL) = 50555;

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    0 | SELECT STATEMENT |      |     1.    13.   470 (6) | 00:00:06 |

    1.  TABLE ACCESS FULL | T    |     1.    13.   470 (6) | 00:00:06 |

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

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

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

    1 - filter (TO_NUMBER (TO_CHAR ("COL")) = 50555)

    Case 4. Where TO_CHAR (COL) = '50555';

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    0 | SELECT STATEMENT |      |     1.    13.   463 (5) | 00:00:06 |

    1.  TABLE ACCESS FULL | T    |     1.    13.   463 (5) | 00:00:06 |

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

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

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

    1 - filter (TO_CHAR ("COL") = '50555')

    Why the access descriptor became predicate to filter in case 3 and 4?

    Please, help me understand.

    ACCESS (Index Scan) - Oracle tries to use an index one try to access a table row that they are interested.

    FILTER (full table scan) - Oracle has no any tool to directly get to the table of ranks it is interested in, so it must pass all the lines and then filter the rows that match the main condition.

  • Name of the PK, unique constraints and to support the index

    I want to have my primary key constraint and index support share of the same name, IE:
    CREATE UNIQUE INDEX MYTABLE_PK ON MYTABLE(...);
    ALTER TABLE MYTABLE ADD CONSTRAINT MYTABLE_PK PRIMARY KEY(...);
    Without definition explicit a unique index using the relational model, the generated DDL added 'X' for the name of the index:
    CREATE UNIQUE INDEX MYTABLE_PKX ON MYTABLE(...);
    ALTER TABLE MYTABLE ADD CONSTRAINT MYTABLE_PK PRIMARY KEY(...);
    I tried to add an index unique explicit to the table, but he changed the name (adds "v1") when I leave the table editor:
    CREATE UNIQUE INDEX MYTABLE_PKv1 ON MYTABLE(...);
    ALTER TABLE MYTABLE ADD CONSTRAINT MYTABLE_PK PRIMARY KEY(...);
    I have the same problem with index & unique constraints.

    Issues related to the:
    Can I generate DDL with name matching? "v1" thing seems unlikely, he doesn't want not myself save the definition as I want.
    Where are the transformations of naming for this location? I found tools, preferences, and Data Modeling/naming Standards/Templates but this nugget does nto seem to be there.

    Thank you.

    Hi Mike,.

    The Production data release model 3.1 has been updated to allow constraints unique and primary and their indexes share the same name.

    David

  • Unique and non-unique indexes


    Hello

    I have a unique index associated with no doubt. Unique and not unique indexes are used B tree architecture. But I want to know if I create a non-unique index on a column that contains unique data.

    When I query this table using this column, it scans each sheet or times found that value it scan stops and give us the result?

    00125 wrote:

    In a non-unique index, scans all the leaves... so what's the difference between full table scan and index ull. I went through a few articles they mentioned that a non-unique index to check with rowid. How she treated? I have clear knowledge in it.

    Please help me with this.

    Thanks in advance

    If you go through architecture index B-tree you could easily understand how indexing works. The picture here shows how a look of column datatype NUMBER indexed as / stored internally. You can imagine that your indexed column TST_COLA this will look like in the internal process. In the B-tree indexes, you have 3 main structures 1. 2 root. Branch 3. Leaves and the database retrieves lines by browsing through the root of index-> branch-> leaves. If the photo if we wanted to retrieve the row whose value indexed column = 25. First data goes to the root and finds that plugs is set to 25, then he Stoops to this particular branch of find what block sheet retains the value 25. More far away after finding the leaves block then goes to this block of sheets and research the special value of 25.

    If the index is UNIQUE, the database knows that there must be only one value, where it performs INDEX UNIQUE SCAN. If the index is NOT UNIQUE it should check all values in this block of leaves to find who all are 25 - in this case INDEX RANGE SCAN is done - as you must check not only value, but all values in this block of sheets - given that the values are not unique. As you can see it that the sheet block contains the long side of the value of the column ROWID, using this database rowid, then goes to the table to retrieve that particular line.

    Full table scan is a method of access where the database just to access the table directly (bypassing index structure) and analyze the ENTIRE table to satisfy the request.

  • Reg: Cursor (implicit / explicit)

    Dear gurus,

    Could you please give me advice on this code below. It is below an implicit cursor / explicit cursor. Insofar that I studied (correct me if wrong), a select statement runs at the SQL prompt, it is supposed to be as implicit cursor.  But, this one is explicit, as we wrote in the PLSQL block and you can call it as a CURSOR for LOOP.

    SQL > ed

    A written file afiedt.buf

    1 start

    2 for i in (select ename from emp)

    loop 3

    4 dbms_output.put_line (' name :'|| i.ename);

    5 end of loop;

    6 * end;

    SQL > /.

    Name: SMITH

    Name: ALLEN

    Name: WARD

    Name: JONES

    Name: MARTIN

    Name: BLAKE

    Name: CLARK

    Name: SCOTT

    Name: KING

    Name: TURNER

    Name: ADAMS

    Name: JAMES

    Name: FORD

    Name: MILLER

    PL/SQL procedure successfully completed.

    Thank you.

    Hello

    IMPLICIT cursor: Implicit cursor is created "automatically" for you by Oracle when you run a query.

    Example: SELECT ename FROM emp;

    EXPLICIT CURSOR: You create your own explicit cursor.

    DECLARE

    VARCHAR2 (20) var1;

    CURSOR cur IS SELECT ename FROM emp where empno = 7566;

    BEGIN

    Heart OPEN;      -Opening the cursor

    Fetch cur INTO var;

    CLOSE cur;    -Closing of the cursor, if we free the memory occupied by this cursor

    END;

    The code you gave is also implicit cursor only.

  • Additional logging on unique indexes

    Hello
    I enabled logging on a unique index on an extra table...
    Table emp (id number, name varchar2 (20), varchar2 (20)) of the grid;

    create an index unique emp_id on emp (id, name);

    change the emp table add extra newspaper group emp_supp (id, name);

    Now if I update the column in the grid for a record will it produce data of additional journal for the unique index columns?

    Hello

    Yes, he does.
    refer to the doc: http://download.oracle.com/docs/cd/B13789_01/server.101/b10823/create_ls.htm

    -Pavan Kumar N

  • unique index on two columns

    Hi all
    I want a unique index on two columns, but when I try this it will show me
      1  CREATE UNIQUE INDEX sale_order_no
      2*   ON sale_order (sale_order_no, season_year)
    SQL> /
      ON sale_order (sale_order_no, season_year)
         *
    ERROR at line 2:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    I want to do not overlap with the combination of these two

    Plaese Guide
    Thanks and greetings
    Vikas

    You would this behavior if SALE_ORDER_NO has NULL values. If it contains NULL values, a unique single-column index will succeed but an index unique multi-column will fail when it finds duplicates in SEASON_YEAR.

    See:

    SQL> create table dummy_objects (object_id  number, object_owner varchar2(30), object_name varchar2(30));
    
    Table created.
    
    SQL> insert into dummy_objects values (0,'HEMANT','TABLE_A');
    
    1 row created.
    
    SQL> insert into dummy_objects values (1,'HEMANT','TABLE_B');
    
    1 row created.
    
    SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_1');
    
    1 row created.
    
    SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_2');
    
    1 row created.
    
    SQL> create unique index dummy_objects_u1 on dummy_objects(object_id);
    
    Index created.
    
    SQL> drop index dummy_objects_u1;
    
    Index dropped.
    
    SQL> create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner);
    create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner)
                                            *
    ERROR at line 1:
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    
    SQL>
    

    Hemant K Collette
    http://hemantoracledba.blogspot.com

  • UNIQUE compared to a NON-UNIQUE INDEX

    Hello SQL gurus.

    Can you tell me the difference between UNIQUE and NON-UNIQUE index?

    Thank you
    Dave

    The fact that a UNIQUE index will not allow duplicate values in the columns in Index key so that NO SINGLE index will allow duplicates.

    If I CREATE an INDEX UNIQUE MY_TABLE_UK ON MY_TABLE (NAME_COLUMN);

    I can't insert the value "HEMANT" twice in the NAME_COLUMN.

    If I CREATE INDEX MY_TABLE_IDX ON MY_TABLE (NAME_COLUMN);

    I can "HEMANT" insert multiple lines.

    NOTE: If I insert NULL values, a UNIQUE INDEX will allow several NULL values as, by definition "NULL! = NULL ". However, a definition of primary key does not allow nulls.

  • Why choose wrong explain plan when there is a unique index

    SQL > create table test in select * from dba_objects;

    Table created.

    SQL > create table test1 in select * from user_objects;

    Table created.

    SQL > create index unique i_test_1 on test (object_id);

    The index is created.

    SQL > exec dbms_stats.gather_table_stats (user, 'TEST');

    PL/SQL procedure successfully completed.

    SQL > exec dbms_stats.gather_table_stats (user, 'TEST1');

    PL/SQL procedure successfully completed.

    SQL > set autot trace
    SQL > select test1.* from test, test1 where test.object_id = test1.object_id;

    23037 selected lines.


    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 3995284093

    -------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    -------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 23038 | 2114K | 77 (12) | 00:00:01 |
    | 1. NESTED LOOPS | 23038 | 2114K | 77 (12) | 00:00:01 |
    | 2. TABLE ACCESS FULL | TEST1 | 23038 | 2002K | 70 (3) | 00:00:01 |
    |* 3 | INDEX UNIQUE SCAN | I_TEST_1 | 1. 5. 0 (0) | 00:00:01 |
    -------------------------------------------------------------------------------

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

    3 - access("TEST".") OBJECT_ID '= 'TEST1'.' OBJECT_ID')


    Statistics
    ----------------------------------------------------------
    494 recursive calls
    0 db block Gets
    26457 consistent gets
    0 physical reads
    0 redo size
    1090589 bytes sent via SQL * Net to client
    17270 bytes received via SQL * Net from client
    1537 SQL * Net back and forth to and from the client
    5 kinds (memory)
    0 sorts (disk)
    23037 rows processed


    SQL > drop index i_test_1;

    The index is deleted.

    SQL > create index i_test_1 on test (object_id);

    The index is created.

    SQL > set autot trace
    SQL > select test1.* from test, test1 where test.object_id = test1.object_id;

    23037 selected lines.


    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 845425162

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time
    |

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

    | 0 | SELECT STATEMENT | 23038 | 2114K | 99 (6) | 00:00:02
    |

    |* 1 | HASH JOIN | 23038 | 2114K | 99 (6) | 00:00:02
    |

    | 2. FULL RESTRICTED INDEX SCAN FAST | I_TEST_1 | 49887 | 243K | 27 (4) | 00:00:01
    |

    | 3. TABLE ACCESS FULL | TEST1 | 23038 | 2002K | 70 (3) | 00:00:01
    |

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


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

    1 - access("TEST".") OBJECT_ID '= 'TEST1'.' OBJECT_ID')


    Statistics
    ----------------------------------------------------------
    1 recursive calls
    0 db block Gets
    1936 complies
    411 physical reads
    0 redo size
    1090589 bytes sent via SQL * Net to client
    17270 bytes received via SQL * Net from client
    1537 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    23037 rows processed

    I think the hash join is the real plan, why choose nest loop where there is a unique index.

    Jinyu wrote:
    I think that thought cbo cost single scan index is 0, so loop nest is less expensive than the hash join, but I do not know why here costs 0

    Jinyu,

    You are right - in a nested loop, the CBO gives unique access by unique index value slightly cheaper than the same access by a non-unique index--essentially subtracting 1 of the normal cost.

    It is one of the reasons why you only need to create a no unique index to support a unique constraint, if you have a very good reason - if you modify a unique index that is not unique, change of costs and execution of some paths may change.

    Concerning
    Jonathan Lewis

Maybe you are looking for

  • Cannot record audio CD player (Equium A60-155)

    Audio CD play disc ok, but can not save as ".wav" using sound recorder in Windows or the AV basket supplied with the system. I have configured the noise map I / O and volume sliders but still no luck - it an option is grayed out on the properties of

  • How to acquire the generated signal?

    Ladies and gentlemen, I am a novice in LabVIEW even if I practice solving problems more or less difficult, I got NOR cDAQ-9178, possess an entrance connected with output channels and after a plan of work on the signal acquisition and production separ

  • TPC-2106 t related query

    I want to connect TPC-2106 t with the CompactRIO-9014 cable RS-232 (serial). Could I connect to end of data i.e. communication to send orders in real time PTC VI, who will present the CompactRIO and receive data from the PTC something generating VI r

  • Could not load down the updates of security forJscript 5.8

    Can not download updates of security for Jscript 5.0 and Windows XP (KB956844)

  • How can I install Windows 7 on a desktop Dell running two Partitions XP?

    We have a Dell XPS 400 machine running Windows XP Home Edition with two partitions, the ethat on is used, and then an elder who has been corrupted and restored.  Nevertheless, we have tried to install Windows 7 Professional 64 - Bit Version on a CD.