How can i know if my query is using the index ?

Hello...
How can i know if my query is using the index of the table or not?
im using set autotrace on...but is there another way to do it?
thanks!
Alessandro Falanque.

Hi,
You can use Explain Plan for checking that your query is using proper index or not. First you need to check that Plan_table is installed in your database or not. If it is not there THEN THE SCRIPT WILL BE LIKE THIS:
CREATE TABLE PLAN_TABLE (
STATEMENT_ID VARCHAR2 (30),
TIMESTAMP DATE,
REMARKS VARCHAR2 (80),
OPERATION VARCHAR2 (30),
OPTIONS VARCHAR2 (30),
OBJECT_NODE VARCHAR2 (128),
OBJECT_OWNER VARCHAR2 (30),
OBJECT_NAME VARCHAR2 (30),
OBJECT_INSTANCE NUMBER,
OBJECT_TYPE VARCHAR2 (30),
OPTIMIZER VARCHAR2 (255),
SEARCH_COLUMNS NUMBER,
ID NUMBER,
PARENT_ID NUMBER,
POSITION NUMBER,
COST NUMBER,
CARDINALITY NUMBER,
BYTES NUMBER,
OTHER_TAG VARCHAR2 (255),
PARTITION_START VARCHAR2 (255),
PARTITION_STOP VARCHAR2 (255),
PARTITION_ID NUMBER,
OTHER LONG,
DISTRIBUTION VARCHAR2 (30))
TABLESPACE SYSTEM NOLOGGING
PCTFREE 10
PCTUSED 40
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 10240
NEXT 10240
PCTINCREASE 50
MINEXTENTS 1
MAXEXTENTS 121
FREELISTS 1 FREELIST GROUPS 1 )
NOCACHE;
After that write the following command in the SQL prompt.
Explain plan for (Select statement);
Select level, SubStr( lpad(' ',2*(Level-1)) || operation || ' ' ||
object_name || ' ' || options || ' ' ||
decode(id, null , ' ', decode(position, null,' ', 'Cost = ' || position) ),1,100)
|| ' ' || nvl(other_tag, ' ') Operation
from PLAN_TABLE
start with id = 0
connect by
prior id = parent_id;
This will show how the query is getting executed . What are all the indexes it is using etc.
Cheers.
Samujjwal Basu

Similar Messages

  • I lost my Iphone 3GS. My brother has given me his Iphone 4 now. We both use the same notebook to update and sync our phones. I would like to know how can i reconnect back to my account using the Iphone which was previous used by my brother.

    I lost my Iphone 3GS. My brother has given me his Iphone 4 now. We both use the same notebook to update and sync our phones. I would like to know how can i reconnect back to my account using the Iphone which was previous used by my brother.

    If you are saying that you both have iCloud accounts and use the same icloud ID, then yes, the contacts will be deleted.  The idea is that all devices using the same icloud ID are kept in sync.  You need to use different IDs.  You can keep the same iTunes ID so you can share the songs and apps.  But use different icloud IDs.

  • How can i know what transaction is handle by the TM?

    How can i know what transaction is handle by the TM?

    Hi;
    Please see below
    E-Business Oracle Trade Management Product Information Center [ID 1297829.1]
    Regard
    Helios

  • How Can I know about any change happened in the page??

    ........... I Use JDev 11g ........
    How Can I know if any change happened in the page???
    for example:
    I have a page and I press a creation button that create a new row in view object I want when I press any button that will call another page the page ask a user Are you want to save changes? before leaving a page.
    Or
    I edit the value in a view object but not committed ( I didn't commit the data in database ) . When I want to leave the page I want to display a message say : Are you want to save changes?
    How can I do that?
    Thank You...
    Sameh Nassar

    Check out http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html Example 60. Do not go by the 'on page load' name... This approach will allow you to plug in your custom code at any 'phase' of your adf life cycle. You can capture any request coming from your page, and check for pending transaction states and act accordingly.. I realize that the reply is a little abstruse, but this is not a drag-drop-smile requirement.. :-)
    http://download.oracle.com/docs/html/B25947_01/bcdcpal005.htm#sm0271
    Julian

  • How can i Know my ipod nano is under the warranty?

    How can i Know my ipod nano is under the warranty?
    Which link can i click and login to see my warranty status?

    on the support page to your right there is an area where you can put your serial number and it should give you the amount of days left on your warranty if you registered your ipod

  • How Can You Track Your Ipod If Lost Using The Serial Number

    How Can You Track Your Ipod If Lost Using The Serial Number?

    The find my iphone app has nothong to do with it.
    That app simply allow you to find other devices using your ipod.  It has nothing to do with fining the device on which it is installed.
    If you set up the find my ipod feature that is built into your ipod and the ipod is on and it is connected to wi-fi and it has not been restored, then you may be able to get an approximate street address using icloud.
    Othrewise, it cannot be tracked.

  • How can I convert .pdf file to .doc using the free adobe reader app? when I try to convert the .pdf file it asks me to sign in. when I click on "sign in", I am taken to a service subscription page. So, no free conversions using free adobe reader app?

    how can I convert .pdf file to .doc using the free adobe reader app? when I try to convert the .pdf file it asks me to sign in. when I click on "sign in", I am taken to a service subscription page. So, no free conversions using free adobe reader app?

    As has been mentioned Adobe Reader cannot export PDF page content. Nor can it create PDF or manipulate PDF page content.
    What you can do is use one of Adobe's online subscription services. Two provide for PDF  to Word export.
    There's ExportPDF and PDF Pack.
    Be well...

  • How can I configuration MBean in weblogic server  using the console ?

    How can I configuration MBean in weblogic server using the console ?
    I hear people talking about mbeans in weblogic server I have look in the console I can not find where , or how to do it.
    can some body explain that or a link that explain it, how to do it on the console ?

    Hi,
    Registering Custom MBeans from Admin Console is not yet possible. But yes there are ways to Configure and Utilize Custom MBeans ...
    http://weblogic-wonders.com/weblogic/2010/02/16/registering-and-invoking-custommbeans/
    Thanks
    Jay SenSharma

  • If I download a video from my video camera to a new (current 1/12) iMac 21 inch, how can I burn it to a DVD using the computer itself. Is this possible? Do I need to buy additional software. Two salespeople at the Apple were a little confused about this.

    If I download a video from my video camera to a new (current 1/12) iMac 21 inch, how can I burn it to a DVD using the computer itself. Is this possible? Do I need to buy additional software. Two salespeople at the Apple were a little confused about this. Thank you.

    The DVD recorder I'm referring to is one I've use for years. It is not attached to my aging iMac in any way. I simply play the video from my camcorder (mini-dv tape based Canon HV20)  into the DVD recorder and create a DVD that can be played in any DVD player. I can only do minimum editing so what goes in is what I get. This has been fine for creating dupes of the various things I shoot.
    If I buy a new iMac (21 inch), I'd like to be able to download the video to the iMac through iMovie, work with it to whatever degree I wish, and burn it to a DVD that can also be played in any DVD player -- or to use as a master to dupe copies.
    What I'm understanding from you and others is that this would be possible if Apple had included iDVD in the software that comes with the iMac, or if I purchase the iLife Family Pack, or buy the correct version of Toast. I'm hoping I can persuade Apple to sell me an iMac with iDVD installed.
    Essentially I want to move from a basic process of creating DVD copies to the more sophisticated process of creating one from an iMac.
    Thank you again for your help and wisdom.

  • Why is this query not using the index?

    check out this query:-
    SELECT CUST_PO_NUMBER, HEADER_ID, ORDER_TYPE, PO_DATE
    FROM TABLE1
    WHERE STATUS = 'N'
    and here's the explain plan:-
    1     
    2     -------------------------------------------------------------------------------------
    3     | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    4     -------------------------------------------------------------------------------------
    5     | 0 | SELECT STATEMENT | | 2735K| 140M| 81036 (2)|
    6     |* 1 | TABLE ACCESS FULL| TABLE1 | 2735K| 140M| 81036 (2)|
    7     -------------------------------------------------------------------------------------
    8     
    9     Predicate Information (identified by operation id):
    10     ---------------------------------------------------
    11     
    12     1 - filter("STATUS"='N')
    There is already an index on this column, as is shown below:-
         INDEX_NAME INDEX_TYPE     UNIQUENESS     TABLE_NAME     COLUMN_NAME     COLUMN_POSITION
    1     TABLE1_IDX2 NORMAL     NONUNIQUE     TABLE1      STATUS     1
    2     TABLE1_IDX NORMAL     NONUNIQUE     TABLE1     HEADER_ID     1
    So why is this query not using the index on the 'STATUS' Column?
    I've already tried using optimizer hints and regathering the stats on the table, but the execution plan still remains the same, i.e. it still uses a FTS.
    I have tried this command also:-
    exec dbms_stats.gather_table_stats('GECS','GEPS_CS_SALES_ORDER_HEADER',method_opt=>'for all indexed columns size auto',cascade=>true,degree=>4);
    inspite of this, the query is still using a full table scan.
    The table has around 55 Lakh records, across 60 columns. And because of the FTS, the query is taking a long time to execute. How do i make it use the index?
    Please help.
    Edited by: user10047779 on Mar 16, 2010 6:55 AM

    If the cardinality is really as skewed as that, you may want to look at putting a histogram on the column (sounds like it would be in order, and that you don't have one).
    create table skewed_a_lot
    as
       select
          case when mod(level, 1000) = 0 then 'N' else 'Y' end as Flag,
          level as col1
       from dual connect by level <= 1000000;
    create index skewed_a_lot_i01 on skewed_a_lot (flag);
    exec dbms_stats.gather_table_stats(user, 'SKEWED_A_LOT', cascade => true, method_opt => 'for all indexed columns size auto');Is an example.

  • How can I know which link was clicked in the link list

    Hi everyone
    I'm using list of links in my page to display list of the files in some directory.
    How can I know which link user was clicked. There are some code:
    <%
    String dir = "..//files//";
    File fin = new File(dir);
    File files[]=fin.listFiles();
    for(int i=0;i<files.length;i++)
    File x = files;
    %>
    <%=x.getName()%><br>
    <%
    %>
    Please help

    You need to pass some data on the querystring to the page you are linking to.
    <a href="Main_Work.jsp?file=<%=x.getName()%>"><%=x.getName()%></a><br>
    This will send a parameter called "file" with the value of the file name that the user clicked.
    Now in Main_Work.jsp you can access this data as follows:
    <%
    String s = request.getParameter("file");
    File f = new File("..//files//"+s);
    %>

  • How can I know what apps are running in the background of Q10

    My battery is not lasting more than 12 hours even though I'm moderately using it. How can I tell which applications are running in the background?

    As of now, the BB10 does not allow any apps to run in the background unless they are baked in the OS or in the active frames. So if an app is not in a active frame, no app is running in the background. try maximizing your battery by switching to wif whenever you have a wifi network.
    Twitter: @ukmight
    1. Click on the " Like " button if you find anything helpful posted.
    2. If any of the replies in your post has resolved your problem, mark the reply(ies) as " Solution ", so that others can readily view the solution instead of creating another redundant post.

  • Query not using the index

    Query
    SELECT case.case_objid FROM [email protected] case, table_x_cwp_tickect_details_vw t WHERE CASE.case_condition_cd IN ('OPEN', 'OPEN-DISPATCH', 'OPEN-REJECT', 'OPEN-RETURNED') AND case.case_type_cd in ('CUSTOMER FAULT', 'CHRONIC','SCHEDULED ACTIVITY','PROBLEM') AND ROWNUM <= 500 AND case.case_objid = t.ticket_objid AND ( ( case.account_id = '672286' ) ) ORDER BY case.case_id DESC
    From PROD
    Plan
    SELECT STATEMENT HINT: FIRST_ROWS Cost: 2,629 Bytes: 221,500 Cardinality: 500
         37 SORT ORDER BY Cost: 2,629 Bytes: 221,500 Cardinality: 500
              36 COUNT STOPKEY
                   35 NESTED LOOPS OUTER Cost: 2,628 Bytes: 279,533 Cardinality: 631
                        33 HASH JOIN OUTER Cost: 2,627 Bytes: 275,116 Cardinality: 631
                             31 NESTED LOOPS OUTER Cost: 2,249 Bytes: 266,282 Cardinality: 631
                                  28 NESTED LOOPS Cost: 1,766 Bytes: 257,448 Cardinality: 631
                                       26 NESTED LOOPS Cost: 1,765 Bytes: 253,031 Cardinality: 631
                                            24 NESTED LOOPS Cost: 1,764 Bytes: 248,614 Cardinality: 631
                                                 22 NESTED LOOPS Cost: 1,763 Bytes: 244,197 Cardinality: 631
                                                      19 NESTED LOOPS Cost: 1,258 Bytes: 235,363 Cardinality: 631
                                                           17 NESTED LOOPS Cost: 1,257 Bytes: 230,946 Cardinality: 631
                                                                14 NESTED LOOPS OUTER Cost: 752 Bytes: 217,695 Cardinality: 631
                                                                     12 HASH JOIN Cost: 751 Bytes: 213,278 Cardinality: 631
                                                                          1 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                          11 HASH JOIN Cost: 748 Bytes: 208,861 Cardinality: 631
                                                                               2 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                               10 HASH JOIN Cost: 746 Bytes: 204,444 Cardinality: 631
                                                                                    3 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                                    9 HASH JOIN Cost: 743 Bytes: 200,027 Cardinality: 631
                                                                                         4 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,052 Cardinality: 1,436
                                                                                         8 NESTED LOOPS Cost: 741 Bytes: 195,610 Cardinality: 631
                                                                                              5 REMOTE REMOTE CASE Cost: 235 Bytes: 156,488 Cardinality: 631
                                                                                              7 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_CASE Cost: 1 Bytes: 62 Cardinality: 1
                                                                                                   6 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.TC_C_CASE_OBJINDEX Cost: 1 Cardinality: 1
                                                                     13 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.UN_PTT2CASE Cost: 1 Bytes: 7 Cardinality: 1
                                                                16 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_SITE Cost: 1 Bytes: 21 Cardinality: 1
                                                                     15 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_OBJINDEX Cost: 1 Cardinality: 1
                                                           18 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.BUS_ORG_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                      21 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_ADDRESS Cost: 1 Bytes: 14 Cardinality: 1
                                                           20 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.ADDRESS_OBJINDEX Cost: 1 Cardinality: 1
                                                 23 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.COUNTRY_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                            25 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONTACT_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                       27 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONDITION_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                  30 TABLE ACCESS BY GLOBAL INDEX ROWID TABLE SA.TABLE_SITE_PART Cost: 1 Bytes: 14 Cardinality: 1 Partition #: 34
                                       29 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_PART_OBJINDEX Cost: 1 Cardinality: 1
                             bold 32 TABLE ACCESS FULL TABLE SA.TABLE_MOD_LEVEL Cost: 376 Bytes: 1,442,084 Cardinality: 103,006 bold
                        34 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.PART_NUM_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
    From DEV platform
    Plan
    SELECT STATEMENT HINT: FIRST_ROWS Cost: 591 Bytes: 61,134 Cardinality: 138
         37 SORT ORDER BY Cost: 591 Bytes: 61,134 Cardinality: 138
              36 COUNT STOPKEY
                   35 HASH JOIN Cost: 590 Bytes: 61,134 Cardinality: 138
                        1 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                        34 HASH JOIN Cost: 588 Bytes: 60,168 Cardinality: 138
                             2 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                             33 HASH JOIN Cost: 585 Bytes: 59,202 Cardinality: 138
                                  3 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                                  32 HASH JOIN Cost: 583 Bytes: 58,236 Cardinality: 138
                                       4 INDEX FAST FULL SCAN INDEX (UNIQUE) SA.GBST_ELM_OBJINDEX Cost: 2 Bytes: 10,045 Cardinality: 1,435
                                       31 NESTED LOOPS OUTER Cost: 580 Bytes: 57,270 Cardinality: 138
                                            29 NESTED LOOPS OUTER Cost: 579 Bytes: 56,304 Cardinality: 138
                                                 27 NESTED LOOPS OUTER Cost: 469 Bytes: 54,372 Cardinality: 138
                                                      24 NESTED LOOPS Cost: 363 Bytes: 52,440 Cardinality: 138
                                                           22 NESTED LOOPS Cost: 362 Bytes: 51,474 Cardinality: 138
                                                                20 NESTED LOOPS Cost: 361 Bytes: 50,508 Cardinality: 138
                                                                     18 NESTED LOOPS Cost: 360 Bytes: 49,542 Cardinality: 138
                                                                          15 NESTED LOOPS Cost: 249 Bytes: 47,610 Cardinality: 138
                                                                               13 NESTED LOOPS Cost: 248 Bytes: 46,644 Cardinality: 138
                                                                                    10 NESTED LOOPS OUTER Cost: 138 Bytes: 43,746 Cardinality: 138
                                                                                         8 NESTED LOOPS Cost: 137 Bytes: 42,780 Cardinality: 138
                                                                                              5 REMOTE REMOTE CASE Cost: 26 Bytes: 34,224 Cardinality: 138
                                                                                              7 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_CASE Cost: 1 Bytes: 62 Cardinality: 1
                                                                                                   6 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.TC_C_CASE_OBJINDEX Cost: 1 Cardinality: 1
                                                                                         9 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.UN_PTT2CASE Cost: 1 Bytes: 7 Cardinality: 1
                                                                                    12 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_SITE Cost: 1 Bytes: 21 Cardinality: 1
                                                                                         11 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_OBJINDEX Cost: 1 Cardinality: 1
                                                                               14 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.BUS_ORG_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                                          17 TABLE ACCESS BY INDEX ROWID TABLE SA.TABLE_ADDRESS Cost: 1 Bytes: 14 Cardinality: 1
                                                                               16 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.ADDRESS_OBJINDEX Cost: 1 Cardinality: 1
                                                                     19 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.COUNTRY_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                                21 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONTACT_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                           23 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.CONDITION_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
                                                      26 TABLE ACCESS BY GLOBAL INDEX ROWID TABLE SA.TABLE_SITE_PART Cost: 1 Bytes: 14 Cardinality: 1 Partition #: 34
                                                           25 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.SITE_PART_OBJINDEX Cost: 1 Cardinality: 1
                                       bold           28 INDEX RANGE SCAN INDEX SA.IND_PART_INFO2PART_NUM Cost: 1 Bytes: 14 Cardinality: 1 bold
                                            30 INDEX UNIQUE SCAN INDEX (UNIQUE) SA.PART_NUM_OBJINDEX Cost: 1 Bytes: 7 Cardinality: 1
    Conclusion:
    IND_PART_INFO2PART_NUM is not in use in Production environment
    PROD
    1. SQL> select index_name,NUM_ROWS,CLUSTERING_FACTOR from dba_indexes where index_name='IND_PART_INFO2PART_NUM';
    INDEX_NAME NUM_ROWS CLUSTERING_FACTOR
    IND_PART_INFO2PART_NUM 103023 46488
    DEV environment
    SQL> select index_name,NUM_ROWS,CLUSTERING_FACTOR,table_name from dba_indexes where index_name='IND_PART_INFO2PART_NUM';
    INDEX_NAME NUM_ROWS CLUSTERING_FACTOR TABLE_NAME
    IND_PART_INFO2PART_NUM 101982 45722 TABLE_MOD_LEVEL
    1. Index is rebuild
    2. stats are up to date
    3. Redef on table is done.
    Still no change in the plan .

    Osama-mustafa wrote:
    Aman.... wrote:
    Osama-mustafa wrote:
    alter index <index-name> rebuild ;Why?
    Aman....I faced this issue with query and indexes was need rebuildWhat issue Osama-that query wasn't using index and after rebuild it did start using it? Not just that this reply is wrong , this is OP has mentioned that he has done already. Please note that index rebuild is not the answer when the query is not using the index. There can be many reasons behind it. Have a look at Richard Foote's blog where he explains all of this in a very detailed way and in many posts.
    Aman....

  • How can I know, which RFC connection is used by my query designer ?

    HI,
    I would like to know,
    which RFC connection is used when i launch the query designer or the report designer or the web designer.
    Thanks.
    Guillaume

    Hi,
    Go to TCODE SM59 and see.
    Regards
    Nilesh

  • How can i refresh view on query after changing the query?

    Hi,
    i built few view's on 1 query in BI7. after i made a change in the query i haven't seen it in the view, why?
    it's not refreshing automaticly from the query? and if it's not, how can i refresh the view?
    thanks
    Meirav
    Edited by: Meirava on Apr 2, 2009 11:43 AM

    Hi,
        You need to refresh that view and once again save the view with changed settings. Then it will brings according to the query changes.Once check the variables also.
    Regards
    Pcrao.

Maybe you are looking for