Indexes in table join

Hi Experts,
I have three tables and I am using a join condition to link the three tables. Just need to know how can I improve the performance of the select query by using indexes. Can a secondary index be used in join table where in the where clause i have attributes from three different tables. If yes how do I do it.
Please suggest solution with examples.
Help will be much appreciated.
Regards.

Hi
joining 3 tables may refer in bad performance
because if the number of table or 2 then you can go for joins
if the number of tables are more than 2 then use for all entries
because if you use more than 3 tables in the data base connection will be there for that 3 tables up to displaying the data
if you use for all entries then no need of joining the tables
finally
for all entries have more performance than joins
<b>Primary and secondary indexes</b>
Index: Technical key of a database table.
Primary index: The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.
Secondary index: Additional indexes could be created considering the most frequently accessed dimensions of the table.
<b>Structure of an Index</b>
An index can be used to speed up the selection of data records from a table.
An index can be considered to be a copy of a database table reduced to certain fields. The data is stored in sorted form in this copy. This sorting permits fast access to the records of the table (for example using a binary search). Not all of the fields of the table are contained in the index. The index also contains a pointer from the index entry to the corresponding table entry to permit all the field contents to be read.
When creating indexes, please note that:
An index can only be used up to the last specified field in the selection! The fields which are specified in the WHERE clause for a large number of selections should be in the first position.
Only those fields whose values significantly restrict the amount of data are meaningful in an index.
When you change a data record of a table, you must adjust the index sorting. Tables whose contents are frequently changed therefore should not have too many indexes.
Make sure that the indexes on a table are as disjunctive as possible.
(That is they should contain as few fields in common as possible. If two indexes on a table have a large number of common fields, this could make it more difficult for the optimizer to choose the most selective index.)
<b>Accessing tables using Indexes</b>
The database optimizer decides which index on the table should be used by the database to access data records.
You must distinguish between the primary index and secondary indexes of a table. The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
If the index fields have key function, i.e. they already uniquely identify each record of the table, an index can be called a unique index. This ensures that there are no duplicate index fields in the database.
When you define a secondary index in the ABAP Dictionary, you can specify whether it should be created on the database when it is activated. Some indexes only result in a gain in performance for certain database systems. You can therefore specify a list of database systems when you define an index. The index is then only created on the specified database systems when activated
<b>Reward if usefull</b>

Similar Messages

  • Context index can't be used in complicated multiple tables join?

    hello
    thank you for view this page.
    i have a comlicated sql :
    SELECT count(*)
    from
    ((app_AssetBasicInfo left join app_AssetBasicInfoExt on
    app_AssetBasicInfo.id=app_AssetBasicInfoExt.id) left join
    (app_AssetCustominfo1 left join app_AssetCustominfoExt1 on
    app_AssetCustominfo1.id=app_AssetCustominfoExt1.id) on
    app_AssetBasicInfo.id=app_AssetCustominfo1.id) WHERE
    app_AssetBasicInfo.CategoryID=1 AND Del_tag=0 and contains(description,'department')>0;
    the table app_AssetBasicInfo and app_AssetBasicInfoExt have multiple columns and large recoord size. i create a context index on app_assetbasicinfoext(description) which description is 4000 varchar2.
    but the sql doesn't use context index. i suspect that the complicated multiple table join can't use context index? does it correct?
    thanks very much!

    Could you please post an explain plan? I'm not quite sure what is the issue.

  • 3 Table Join with group by and order by clauses

    I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
    select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
    It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
    I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
    (see below for my work around)
    I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
    Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
    I really appreciate anyone's input. Thanks,
    Inder
    WORK AROUND:
    FIRST STEP:
    "create TABLE BIDSUM as
    select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
    NEXT STEP:
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
    THIS ALSO WORKS (no LIKE):
    "select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
    BUT THIS DOES NOT (alias the DATE arimetic)
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__';

    I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
    select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
    It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
    I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
    (see below for my work around)
    I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
    Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
    I really appreciate anyone's input. Thanks,
    Inder
    WORK AROUND:
    FIRST STEP:
    "create TABLE BIDSUM as
    select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
    NEXT STEP:
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
    THIS ALSO WORKS (no LIKE):
    "select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
    BUT THIS DOES NOT (alias the DATE arimetic)
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__';

  • Cost of remote db table join

    How expensive is remote db table join?
    In performance tuning a sql statement, I have a query join a local table to two remote tables, it took 9 sec to return 6000+ rows. If I copy the two remote tables to local db, it took 700 msec. All joins/indexes are identical. The remote db is in the same box as the local db.

    I am only asking for general opinion for experience on remote db table join. From explain plan, I already know it's doing next loop index join on the primary key on the two remote db tables. Only one coluum needed from each remote table. Does it look unusual expensive for 6000 primary key join to remote db tables?. 4 sec for each remote table, added up to 8 sec. The rest of processing is minimal.

  • How can I use Indexed Temp tables to optimize performance?

    Instead of joining two CTEs together, I am now going to attempt to join two indexed temp tables. 
    The first temp table is a number of encounters that returns 147 rows in 2 seconds. The second temp table
    is progress notes for all those encounters returning 136 rows in 18 seconds. Joining the indexed views comes back at 3 1/2 minutes.
    What can I do to optimize performance?
    Code is below. Thanks in advance!
    if object_id('tempdb..#arpb') is not null begin drop table #arpb end;
    if object_id('tempdb..#progress_notes') is not null begin drop table #progress_notes end;
    SELECT DISTINCT
    ARPB.PAT_ENC_CSN_ID, ARPB.SERVICE_DATE, ARPB.BILLING_PROV_ID, ARPB.DEPARTMENT_ID,
    SER.PROV_NAME, DEP.DEPARTMENT_NAME, E.APPT_TIME, ZC_APPT.NAME AS APPT_STATUS
    INTO #arpb
    FROM ARPB_TRANSACTIONS ARPB
    LEFT OUTER JOIN CLARITY_SER AS SER ON SER.PROV_ID = ARPB.BILLING_PROV_ID
    LEFT OUTER JOIN CLARITY_DEP AS DEP ON DEP.DEPARTMENT_ID = ARPB.DEPARTMENT_ID
    LEFT OUTER JOIN PAT_ENC AS E ON E.PAT_ENC_CSN_ID = ARPB.PAT_ENC_CSN_ID
    LEFT OUTER JOIN ZC_APPT_STATUS AS ZC_APPT ON ZC_APPT.APPT_STATUS_C = E.APPT_STATUS_C
    WHERE ARPB.DEPARTMENT_ID = xxxx
    AND ARPB.TX_TYPE_C = 1
    AND ARPB.VOID_DATE IS NULL
    AND ARPB.BILLING_PROV_ID = xxxx
    AND ARPB.SERVICE_DATE BETWEEN
    'xxxx' AND 'xxxxx'
    create clustered index idx_temp_arpb on #arpb(PAT_ENC_CSN_ID)
    SELECT DISTINCT
    ARPB.PAT_ENC_CSN_ID,
    ZCNT.NAME AS NOTE_TYPE, PR.NAME AS PURPOSE, HNO_INFO.NOTE_ID,
    EMP.NAME AS EMP_NAME, STS.NAME AS NOTE_STATUS
    INTO #progress_notes
    FROM ARPB_TRANSACTIONS ARPB
    LEFT OUTER JOIN ENC_NOTE_INFO AS ENC_NOTE_INFO ON ARPB.PAT_ENC_CSN_ID = ENC_NOTE_INFO.PAT_ENC_CSN_ID
    LEFT OUTER JOIN HNO_INFO AS HNO_INFO ON ENC_NOTE_INFO.ENCOUNTER_NOTE_ID = HNO_INFO.NOTE_ID
    LEFT OUTER JOIN ZC_NOTE_TYPE AS ZCNT ON ZCNT.NOTE_TYPE_C = ENC_NOTE_INFO.NOTE_TYPE_C
    LEFT OUTER JOIN ZC_NOTE_PURPOSE AS PR ON PR.NOTE_PURPOSE_C = HNO_INFO.NOTE_PURPOSE_C
    LEFT OUTER JOIN CLARITY_EMP AS EMP ON EMP.EPIC_EMP_ID = HNO_INFO.CURRENT_AUTHOR_ID
    LEFT OUTER JOIN ZC_NOTE_STATUS AS STS ON STS.NOTE_STATUS_C = ENC_NOTE_INFO.NOTE_STATUS_C
    WHERE ARPB.DEPARTMENT_ID = xxxx
    AND ARPB.TX_TYPE_C = 1
    AND ARPB.VOID_DATE IS NULL
    AND ARPB.BILLING_PROV_ID = xxxx
    AND ZCNT.NAME = 'xxxx'
    AND ARPB.SERVICE_DATE BETWEEN
    'xxxx' AND 'xxxx'
    AND PR.NAME = 'xxxxx'
    create index idx_temp_pn on #progress_notes(PAT_ENC_CSN_ID)
    SELECT
    #arpb.PAT_ENC_CSN_ID,
    #arpb.APPT_TIME,
    #arpb.SERVICE_DATE,
    #arpb.BILLING_PROV_ID,
    #arpb.PROV_NAME,
    #arpb.DEPARTMENT_ID,
    #arpb.DEPARTMENT_NAME,
    #progress_notes.EMP_NAME as NoteEmp,
    CASE #progress_notes.NOTE_ID
    WHEN null THEN 'No Progress Note'
    ELSE #progress_notes.NOTE_ID
    END as NoteId,
    #progress_notes.NOTE_STATUS,
    #progress_notes.NOTE_TYPE,
    #progress_notes.PURPOSE
    FROM #ARPB
    LEFT JOIN #PROGRESS_NOTES ON #ARPB.PAT_ENC_CSN_ID = #PROGRESS_NOTES.PAT_ENC_CSN_ID
    To err is human, to REALLY foul things up requires a computer

    Something is not right here. What is the type of that column in both temp tables?
    I would assume that joining 147 and 136 rows should be done in less than 1 sec. even without indexes.
    How did you measure the time?
    BTW, I suggest to use aliases in your last query - it will be easier to read. Also use COALESCE function instead of CASE for the Note_ID (BTW, is Note_ID a character column - otherwise you supposed to get an error).
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Creation of context index on index-organized table

    I encountered a problem when creating a domain index(intermediate text context index) on a index-organised table in oracle 8i.
    The description of the error is stated below:
    "ORA-29866: cannot create domain index on a column of index-organized table "
    I have configured intermediate text properly and even it worked for those tables which are not index-organised(ordinary tables).
    This problem has occured only when i made the tables as index organised.
    Please provide us a solution to this problem as early as possible.
    In case if you require any more details i shall provide them.

    Please ask questions about Oracle Text (formerly interMedia text) in the Oracle Text forum. You will get a quicker, more expert answer there.

  • Creation of context index on index-organized tables

    I encountered a problem when creating a domain index(intermediate text context index) on a index-organised table in oracle 8i.
    The description of the error is stated below:
    "ORA-29866: cannot create domain index on a column of index-organized table "
    I have configured intermediate text properly and even it worked for those tables which are not index-organised(ordinary tables).
    This problem has occured only when i made the tables as index organised.
    Please provide us a solution to this problem as early as possible.
    In case if you require any more details i shall provide them.

    creation of domain indexes (such as context) on iot's
    is not currently supported in oracle.

  • What is index oragnized table

    hi can you tell me
    1.what is index oragnized table
    2. fragmentation of table
    3. what is cascading trigger mean

    Hi,
    For this points a good starting point are Oracle Manuals. For index organizated tables check this link [Overview of Index-Organized Tables|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref1044].
    Cascading triggers should be avoided, see this link [Some Cautionary Notes about Triggers|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/triggers.htm#sthref3187]
    Regards,
    Edited by: Walter Fernández on Jan 28, 2009 4:21 PM - Adding information about cascading triggers

  • Index Vs table partition

    I have table whose growth is 1 million per month and may increase in future. I currently place an index on column which is frequently uses in where clause. there is another column which contains months so it may possible that I make 12 partitions of that. I want to know what is suitable. is there any connection between index and table partition?
    Message was edited by:
    user459835

    I think the question is more of what type of queries are answered by this table?
    is it that most of the times the results returned span across several months?
    is there any relation to the column you use in where clause with the data belonging to a particular month (or range there-of)?

  • Order Query in SQ01 using Table Joins in CRM

    Hello Experts,
    I am trying to create a query using table joins in SQ01 in CRM because I need a report that will give me all transactions for a selected Business Partner.  I am unable to display any results when running my query.  I have found other threads which give a list of possible tables to join together, but the fields used in the joins were not described. 
    The tables I have joined in my query are as follows:
    CRMD_ORDERADM_H
    CRMD_ORDER_INDEX
    CRMD_PARTNER
    BUT_000
    I have used SE16 to try to search for additional tables to use for linking the Business Partner with a transaction, but I have been unsuccessful.
    Would anyone please give advice as how to proceed? 
    Reward points are available!
    Thank you in advance,
    David

    David
    The link with be the GUID.
    CRMD_ORDERADM_H = Document Header Table
    CRMD_ORDERADM_I = Document Line item Table
    CRMD_LINK = Lists various ‘link’ GUIDs, to
    access order Information
    The Table CRMD_ORDERADM_H will contain you transactions , once you find the GUID of your sales transaction in the table CRMD_ORDERADM_H.
    You then need to check the table CRMD_LINK.
    In this table you will then find a number in 11 = sales. This refers to the table CRMD_SALES. There are also links to many other tables ie Shipping, pricing, org etc.
    CRMM_BUT_SET0140 - for Sales Group, Sales Office, District
    CRMM_BUT_LNK0141 - for Sales Area data
    Transaction CRMD_BUS2000115 allows you to see all sales transactions for a BP. CRMD_BUS2000126 shows you activities for selected BP.
    Regards
    M

  • Creation of secondary indexes for table "RSBATCHCTRL_PAR" failed

    Hi ,
    We have installed EHP1 on our BI7.0 system successfully, later we are trying to apply SPS01 for this EHP but we got the follwoing error during TBATG conversion.
    2 EGT092 Conversion of table "RSBATCHCTRL_PAR" was restarted
    2 EGT241 The conversion is continued at step "6"
    2 EGT246 Type of conversion: "T" -> "T"
    2 EGT240XBegin step "RSBATCHCTRL_PAR-STEP6":
    4 EGT281 sql:
    4 ED0314 CREATE
    4 ED0314 INDEX [RSBATCHCTRL_PAR~DB] ON [RSBATCHCTRL_PAR]
    4 ED0314 ( [JOBNAME] ,
    4 ED0314 [JOBCOUNT] ,
    4 ED0314 [SERVER] ,
    4 ED0314 [HOST] ,
    4 ED0314 [WP_NO] ,
    4 ED0314 [WP_PID] ,
    4 ED0314 [PROCESS_TYPE] )
    4 ED0314 WITH ( ONLINE=OFF )
    4 ED0314 ON [PRIMARY]
    2 ED0314 Line 1: Incorrect syntax near '('.
    3 EDA093 "DDL time(___1):" ".........6" milliseconds
    2EEGT236 The SQL statement was not executed
    2EEDI006 Index " " could not be created completely in the database
    2EEGT221 Creation of secondary indexes for table "RSBATCHCTRL_PAR" failed
    2EEGT239 Error in step "RSBATCHCTRL_PAR-STEP6"
    2 EGT253XTotal time for table "RSBATCHCTRL_PAR": "000:00:00"
    2EEGT094 Conversion could not be restarted
    2 EGT067 Request for "RSBATCHCTRL_PAR" could not be executed
    1 ED0327XProcess..................: "ferrari_12"
    1 ED0302X=========================================================================
    1 ED0314 DD: Execution of Database Operations
    1 ED0302 =========================================================================
    1 ED0327 Process..................: "ferrari_12"
    1 ED0319 Return code..............: "0"
    1 ED0314 Phase 001................: < 1 sec. (Preprocessing of TBATG)
    1 ED0314 Phase 002................: < 1 sec. (Partitioning)
    1 ED0309 Program runtime..........: "< 1 sec."
    1 ED0305 Date, time...............: "03.06.2009", "12:47:21"
    1 ED0318 Program end==============================================================
    1 ETP166 CONVERSION OF DD OBJECTS (TBATG)
    1 ETP110 end date and time   : "20090603124721"
    1 ETP111 exit code           : "8"
    1 ETP199 ######################################
    System properties:
    SAP - BI7.0 with EHP1
    Database - MSSQL 2000
    OS - Windows2003
    Please suggest.
    Thanks in advance,
    Pavan.

    > We have installed EHP1 on our BI7.0 system successfully, later we are trying to apply SPS01 for this EHP but we got the follwoing error during TBATG conversion.
    > 2 ED0314 Line 1: Incorrect syntax near '('.
    > 3 EDA093 "DDL time(___1):" ".........6" milliseconds
    > 2EEGT236 The SQL statement was not executed
    This is a known problem with SQL Server 2000, see
    Note 1180553 - Syntax error 170 during index creation on SQL 2000
    I highly suggest upgrading to SQL Server 2005 or 2008.
    Markus

  • Creation of indexes in tables

    SAP 4.7      6.20       Oracle 10g       Windows Server 2003
    Our SAP system was based on SQL.
    Last month it was changed to Oracle 10g.
    We really have a lot of developments ( Z programs ), and it's normal for us to create indexes some times.
    But I don't know if we are supposed to change our habits from now on because of Oracle.
    I have 2 questions :
    1) Is the creation of indexes in tables so effective in Oracle as it was for SQL databases ?
    2) When I create an index, Am I supposed to use the field MANDT as part of the index ?
    Eduardo

    Hi,
    We are on Oracle 10.2.4.0 .My answers for point
    1. Ensure that oracle patches are up-to-date. Also oracle parameters are set correctly.There is one S-note(do not remember right now) which has script file which you can run on your system to find if oracle parameters are set according to recommendation.
    2. Mandt can be used in Z programs.Not a problem.
    For future: Analyze Expensive SQl statements with the help of St03N and St04 for next2-3 months and tune them.
    Does it help

  • Index Organized Tables

    what is logical rowid in IOT?are they stored somwhere physically just like physical rowId's
    what are secondary indexes?
    what it means by leaf block splits?when and how it happens?
    and the primary key constraint for an index-organized table cannot be dropped, deferred, or disabled,,,,,Is it true,,,,,if Yes Then Y
    how does overflow works?how the two clauses are implemented PCTTHRESHOLD and INCLUDING.how they work?
    Edited by: Juhi on Oct 22, 2008 1:09 PM

    I'm sort-of tempted to just point you in the direction of the official documentation (the concepts guide would be a start. See http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#sthref759)
    But I would say one or two other things.
    First, physical rowids are not stored physically. I don't know why you'd think they were. The ROWID data type can certainly be used to store a rowid if you choose to do so, but if you do something like 'select rowid from scott.emp', for example, you'll see rowids that are generated on-the-fly. ROWID is a pseudo-column, not physically stored anywhere, but computed whenever needed.
    The difference between a physical rowid and a logical one used with IOTs comes down to a bit of relational database theory. It is a cast-iron rule of relational databases that a row, once inserted into a table, must never move. That is, the rowid it is assigned at the moment of its first insertion, must be the rowid it 'holds onto' for ever and ever. If you ever want to change the rowids assigned to rows in an ordinary table, you have to export them, truncate the table and then re-insert them: fresh insert, fresh rowid. (Oracle bends this rule for various maintenance and management purposes, whereby 'enable row movement' permits rows to move within a table, but the general case still applies mostly).
    That rule is obviously hopeless for index structures. Were it true, an index entry for 'Bob' who gets updated to 'Robert' would find itself next to entries for 'Adam' and 'Charlie', even though it now has an 'R' value. Effectively, a 'b' "row" in an index must be allowed to "move" to an 'r' sort of block if that's the sort of update that takes place. (In practice, an update to an index entry consists of performing a delete followed by a re-insert, but the physicalities don't change the principle: "rows" in an index must be allowed to move if their value changes; rows in a table don't move, whatever happens to their values)
    An IOT is, at the end of the day, simply an index with a lot more columns in it than a "normal" index would have -so it, too, has to allow its entires (its 'rows', if you like) to move. Therefore, an IOT cannot use a standard ROWID, which is assigned once and forever. Instead, it has to use something which takes account of the fact that its rows might wander. That is the logical rowid. It's no more "physical" than a physical rowid -neither are physically stored anywhere. But a 'physical' rowid is invariant; a logical one is not. The logical one is actually constructed in part from the primary key of the IOT -and that's the main reason why you cannot ever get rid of the primary key constraint on the IOT. Being allowed to do so would equate to allowing you to destroy the one organising principle for its contents that an IOT possesses.
    (See the section entitled "The ROWID Pseudocolumn" and following on this page: http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1845
    So IOTs have their data stored in them in primary key order. But they don't just contain the primary key, but every other column in the 'table definition' too. Therefore, just like with an ordinary table, you might want sometimes to search for data on columns which are NOT part of the primary key -and in that case, you might well want these non-primary key columns to be indexed. Therefore, you will create ordinary indexes on these columns -at this point, you're creating an index on an index, really, but that's a side issue, too! These extra indexes are called 'secondary indexes', simply because they are 'subsidiary indexes' to the main one, which is the "table" itself arranged in primary key order.
    Finally, a leaf block split is simply what happens when you have to make room for new data in an index block which is already packed to the rafters with existing data. Imagine an index block can only contain four entries, for example. You fill it with entries for Adam, Bob, Charlie, David. You now insert a new record for 'Brian'. If this was a table, you could throw Brian into any new block you like: data in a table has no positional significance. But entries in an index MUST have positional significance: you can't just throw Brian in amongst the middle of a lot of Roberts, Susans and Tanyas. Brian HAS to go in between the existing entires for Bob and Charlie. Yet you can't just put him in the middle of those two, because then you'd have five entries in a block, not four, which we imagined for the moment to be the maximum allowed. So what to do? What you do is: obtain a new, empty block. Move Charlie and David's entries into the new block. Now you have two blocks: Adam-Bob and Charlie-David. Each only has two entries, so each has two 'spaces' to accept new entries. Now you have room to add in the entry for Brian... and so you end up with Adam-Bob-Brian and Charlie-David.
    The process of moving some index entries out of one block into a new one so that there's room to allow new entries to be inserted in the middle of existing ones is called a block split. They happen for other reasons, too, so this is just a gloss treatment of them, but they give you the basic idea. It's because of block splits that indexes (and hence IOTs) see their "rows" move: Charlie and David started in one block and ended up in a completely different block because of a new (and completely unrelated to them) insert.
    Very finally, overflow is simply a way of splitting off data into a separate table segment that wouldn't sensibly be stored in the main IOT segment itself. Suppose you create an IOT containing four columns: one, a numeric sequence number; two, a varchar2(10); three, a varchar2(15); and four, a blob. Column 1 is the primary key.
    The first three columns are small and relatively compact. The fourth column is a blob data type -so it could be storing entire DVD movies, multi-gigabyte-sized monsters. Do you really want your index segment (for that is what an IOT really is) to balloon to huge sizes every time you add a new row? Probably not. You probably want columns 1 to 3 stored in the IOT, but column 4 can be bumped off over to some segment on its own (the overflow segment, in fact), and a link (actually, a physical rowid pointer) can link from the one to the other. Left to its own devices, an IOT will chop off every column after the primary key one when a record which threatens to consume more than 50% of a block gets inserted. However, to keep the main IOT small and compact and yet still contain non-primary key data, you can alter these default settings. INCLUDE, for example, allows you to specify which last non-primary key column should be the point at which a record is divided between 'keep in IOT' and 'move out to overflow segment'. You might say 'INCLUDE COL3' in the earlier example, so that COL1, COL2 and COL3 stay in the IOT and only COL4 overflows. And PCTTHRESHOLD can be set to, say, 5 or 10 so that you try to ensure an IOT block always contains 10 to 20 records -instead of the 2 you'd end up with if the default 50% kicked in.

  • Need suggestion on adding Index on table

    Hi,
    There is table called customer_locations in my database which has records about more then 5000 rows, When we write some select query to fetch data from this table takes too much time to load the data.
    Need a suggestion how to add index to increase the performance on this table. also which type of index to be added need a suggestion
    table sql script is mentioned below
    CREATE TABLE "CUSTOMER_LOCATIONS"
    (     "LOCATION_ID" NUMBER NOT NULL ENABLE,
         "COMPANY_NAME" VARCHAR2(512),
         "ADDRESS_LINE_1" VARCHAR2(512),
         "ADDRESS_LINE_2" VARCHAR2(512),
         "PHONE_NUMBER" VARCHAR2(255),
         "FAX_NUMBER" VARCHAR2(255),
         "CITY" VARCHAR2(512),
         "STATE" VARCHAR2(512),
         "ZIP" VARCHAR2(100),
         "COUNTRY" VARCHAR2(255),
         "CREATED_BY" VARCHAR2(512),
         "CREATED_DATE" TIMESTAMP (6),
         "MODIFIED_BY" VARCHAR2(512),
         "MODIFIED_DATE" TIMESTAMP (6),
         "DOMAIN_ID" NUMBER,
         "LOCATION_TYPE" VARCHAR2(255),
         "STATUS" VARCHAR2(50),
         "IB_STATUS" VARCHAR2(100),
         "OLD_LOCATION_ID" VARCHAR2(50),
         CONSTRAINT "SS_CUSTOMER_LOCATIONS_PK" PRIMARY KEY ("LOCATION_ID") ENABLE
    Please suggest
    Thanks
    Sudhir

    Hi Sudhir,
    Since you have no predicates it would be unavoidable to have FULL TABLE SCAN. But let me tell you that FULL TABLE SCANS are not bad.
    Just to help you with, the below code can enunciate the use of Indexes:
    drop table test_table;
    create table test_Table as select * from all_objects where rownum < 5001;
    select * from user_ind_columns where table_name = 'TEST_TABLE';
    --No rows fetched.
    explain plan for
    select object_name || ' is a ' || object_type as OBJ_DESC, object_id
      from test_table;
    --5000 Rows fetched
    select operation, options, object_name, object_alias, object_instance, object_type, optimizer, depth, position, cost, cardinality, cpu_cost, io_cost
    from plan_table;
    OPERATION               OPTIONS     OBJECT_NAME     OBJECT_ALIAS          OBJECT_INSTANCE     OBJECT_TYPE     OPTIMIZER     DEPTH     POSITION     COST     CARDINALITY     CPU_COST     IO_COST
    SELECT STATEMENT     (NULL)     (NULL)          (NULL)                    (NULL)               (NULL)          ALL_ROWS     0          19               19          5000          1698651          19     
    TABLE ACCESS          FULL     TEST_TABLE     TEST_TABLE@SEL$1     1                    TABLE          (NULL)          1          1               19          5000          1698651          19
    alter table test_Table add constraint pk_object_id PRIMARY KEY (object_id);
    explain plan for
    select object_name || ' is a ' || object_type as OBJ_DESC, object_id
      from test_table
    where object_id = 26;
    select operation, options, object_name, object_alias, object_instance, object_type, optimizer, depth, position, cost, cardinality, cpu_cost, io_cost
    from plan_table
    where statement_id = 'WITH_PK';
    OPERATION               OPTIONS               OBJECT_NAME          OBJECT_ALIAS          OBJECT_INSTANCE     OBJECT_TYPE          OPTIMIZER     DEPTH     POSITION     COST     CARDINALITY     CPU_COST     IO_COST
    SELECT STATEMENT     (NULL)               (NULL)               (NULL)                    (NULL)               (NULL)               ALL_ROWS     0          2               2          1               15543          2
    TABLE ACCESS          BY INDEX ROWID     TEST_TABLE          TEST_TABLE@SEL$1     1                    TABLE                              1          1               2          1               15543          2
    INDEX                    UNIQUE SCAN          PK_OBJECT_ID     TEST_TABLE@SEL$1     (NULL)               INDEX (UNIQUE)     ANALYZED     2          1               1          1               8171          1Let me know if it help or if you still have any concerns.
    Regards,
    P
    Edited by: PurveshK on May 29, 2012 12:40 PM

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

Maybe you are looking for

  • My ipod somehow converted my video files to music files...

    Ok, I know it sounds strange, but it happened. I buy weekly episodes of South Park and The Office from iTunes so I have a video to watch while on break at work. The other day I went to watch Season 3 of The Office and the episodes have all vanished!

  • Problem of using formula in select join  statement

    I  would like to use following statement but I can not.(do you have an example of an statement where this wuld work): SELECT  lipsprodh  sum(lipslfimg * lipsumvkz / lipsumvkn)  sum(lipsvolum)  lipsvtweg  likp~wadat_ist INTO CORRESPONDING FIELDS OF TA

  • IDVD 5 - Burning a NTSC version using PAL content

    HELP! I want to create an NTSC DVD in IDVD 5. I selected NTSC in the preferences also under Project Info. I then imported Quicktime files and burnt a disc - The problem is I'm in a PAL region and when I play it on my DVD player - it plays! whereas it

  • Want to De-activate the SERVICE radio button while creating a SC

    Hello, My requirement is while a user create a SC and click on 'Describe Requirement' then the SERVICE radio button will deactivate. I'm using BADI BBP_UI_CONTROL_BADI and method BBP_SC_UI_CTRL, but it is not working.... It will be great if anyone he

  • OBİEE 11.1.1.5 and 11.1.1.6 go URL link in pdf export

    Hi, We have a problem; when we export our report to PDF the action links are corrupt. Example; I created an Action Link that goes to http://www.google.com. In column properties - interaction tab - Column Heading - Primary interaction property = Actio