How to use /*+ INDEX */

Hi friends,
Where can I find documentation for the usage of [*+ INDEX */] in SQL statement?
Thanks,
Peter

First_Rows
The FIRST_ROWS hint explicitly chooses the approach to optimize response time, that is, minimum resource usage to return the first row. Results will be returned as soon as they are identified.
This hint causes the optimizer to make these choices:
If an index scan is available, the optimizer may choose it over a full table scan.
If an index scan is available, the optimizer may choose a nested loops join over a sort-merge join whenever the associated table is the potential inner table of the nested loops.
If an index scan is made available by an ORDER BY clause, the optimizer may choose it to avoid a sort operation.
The optimizer ignores this hint in SELECT statement blocks that contain any of the following syntax:
set operators (UNION, INTERSECT, MINUS, UNION ALL)
GROUP BY clause
group functions
DISTINCT operator
These statements cannot be optimized for best response time because Oracle must retrieve all rows accessed by the statement before returning the first row. If you specify this hint in any of these statements, the optimizer optimizes for best throughput.
Syntax:
/*+ FIRST_ROWS */
Example:
SELECT /*+ FIRST_ROWS */ emplid, cc_descr, ccnxt_descr
FROM ps_dwad_c_dl_vw
WHERE emplid = '0895801'

Similar Messages

  • Regarding how to use index , please give me some example if possible

    Hello everybody:
           Thank you all for your help in  advance .
           would you please tell me how to use index, please give me  some example if possible.  couldn't thank you more!
          best regards .
         Frank

    Index is used for faster access of data base tables.
    An index helps to speed up selection from the database. An index is a sorted copy of selected database table fields.
    The primary index is always automatically created in an ABAP-based SAP system. It consists of the primary key fields of the database table. This means, for each combination of the index fields exists a maximum of one record in the table. This kind of index is called a UNIQUE index.
    If the primary index cannot be used to determine selection result, (for example, the WHERE condition does not contain any primary index fields), the system searches the whole table. To prevent this, and determine the selection result by searching through a restricted number of database records, you can create a secondary index.
    However, you should not define an index for all possible fields in the WHERE condition.
    Check this thread..u have more details.
    In which situation we can use the reading of  index

  • How to use Index, Match, or lookup for multi cell data..

    Hey all,  I'm new to using numbers (any spreadsheet really).  I can't figure out how to make this work.
    What I want to do for example is lookup a weight value in (F) by matching all the criteria in (A),(B),(C),(D) & (E).  If possible I would like my search criteria to match everything exactly except the Temp in (E).  The search temp can be warmer or greater than the temp listed. 
    I've tried using Index and Match together but I can't figure out how to match more than one valvue.  If all the other criteria is matched there should only be one weight to return.  I can match one criteria valvue but it only returns the first or last match.  I need it to match each item and return one weight.  What am I doing wrong??
    Please help, and keep it simple for the stupid me.
    Thanks

    The difficulty here is that MATCH and VLOOKUP return the values from the single row with the first match best fitting the type of match specified. VLOOKUP searches from the bottom of the column, MATCH form the top.
    I'd suggest a rearrangement of your data to allow a search with fewer steps.
    Since you want an exact match for the first four columns and a 'smallest value equal to or greater than' match for the fifth column I would suggest concatenating the values in columns A through E into a single value in a new column F inserted after column E.
    For the part of the data table shown, this concatenated value would remain the same for 13 rows, while the temperature ranges in five degree steps from -20 to +45, then a single three-degree step to 48.
    One value in those concatenated then changes, and the new concatenated value repeats for the next 13 rows with the temperature passing through the same range with the same steps.
    If this pattern is consistent (or even reasonably consistent) through the whole table. then a rearrangement of the data as shown below will greatly reduce table size and search time.
    Each distinct set of values A though D is presented on only a single row, the four values are concatenated in column E, and are followed by the temperature values, one per column, in the header row, with the associated weights for those conditions and that temperature listed across that row.
    Note: weights in row 2 (runway 13) are taken from your table. Boredom with retyping then set in, so those in row 2 (runway 31) are formula generated to present a series of decreasing weights, but bear no other relation to those in your table.
    With the table presented in this form, the search is reduced to a single OFFSET expression, with the ROW offset determined by matching the concatenated value of columns A-D of the Query table with their exact counterpart in the Data table, and the column offset determined by matching the temperature in the Query with its closest less than or equal to match in row 1 of Data.
    Formula:
    Query::F2: =OFFSET(Data :: $A$1,MATCH(A&B&C&D,Data :: $E,0)-1,MATCH(E,Data :: $1:$1,1)-1)
    Not handled: What do you want returned for temperatures less than -20 or greater than +48 degrees? As written, the formula will return a not found error for -21 and below, and the value associated with 48° for 49 and above.
    Regards,
    Barry

  • How to use index, when query has decode/case

    Hi,
    I have the following query
    i have a index on party_id,party_type_Code in the zx_party_tax_profile table But this index is not used as Iam using a decode on the columns of the zx_party_tax_profile table,
    Is there any way i can rewrite the query so that it uses index
    sELECT /*+ INDEX(ZX_PARTY_TAX_PROFILE_U2) */ party_tax_profile_id FROM (SELECT
    ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    ThirdPartyTaxProfileEO.CUSTOMER_FLAG,
    ThirdPartyTaxProfileEO.SITE_FLAG,
    ThirdPartyTaxProfileEO.PARTY_TAX_PROFILE_ID,
    ThirdPartyTaxProfileEO.PARTY_ID,
    ThirdPartyTaxProfileEO.REP_REGISTRATION_NUMBER,
    ThirdPartyTaxProfileEO.OBJECT_VERSION_NUMBER,
    ThirdPartyTaxProfileEO.REGISTRATION_TYPE_CODE,
    ThirdPartyTaxProfileEO.COUNTRY_CODE,
    ThirdPartyTaxProfileEO.MERGED_TO_PTP_ID,
    ThirdPartyTaxProfileEO.MERGED_STATUS_CODE,
    ThirdPartyTaxProfileEO.PROGRAM_APP_NAME,
    ThirdPartyTaxProfileEO.PROGRAM_NAME,
    PartyPEO.PARTY_NAME,
    PartyPEO.PARTY_ID AS PARTY_ID1,
    PartyPEO.PARTY_NUMBER,
    decode(ThirdPartyTaxProfileEO.CUSTOMER_FLAG,
    'Y',decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'SC',
    'C'),
    decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'S',
    NULL)
    ) AS PARTY_USAGE,
    ThirdPartyTaxProfileEO.REP_REGISTRATION_NUMBER AS TAX_REG_NUMBER,
    LkupPartyUsage.MEANING AS PARTY_USAGE_DESC,
    PartyPEO.PARTY_NAME AS PARTY_FULL_NAME,
    PartyPEO.ADDRESS1||','||
    PartyPEO.ADDRESS2||','||
    PartyPEO.ADDRESS3||','||
    PartyPEO.CITY||','||
    PartyPEO.postal_code||','||
    PartyPEO.COUNTRY AS ADDRESS,
    PartyPEO.COUNTRY AS COUNTRY_CODE_TCA,
    TerritoryPEO.TERRITORY_SHORT_NAME AS COUNTRY_NAME,
    PartyPEO.JGZZ_FISCAL_CODE AS TAX_PAYER_ID,
    PartyPEO.DUNS_NUMBER_C AS DUNS_NUMBER,
    PartyPEO.Party_Number as Party_Num_Calc,
    null as REGISTRATION_TYPE_NAME,
    null as ROUNDING_LEVEL_NAME,
    null as ROUNDING_RULE_NAME,
    null as COUNTRY_NAME_PTP,
    'ZX_PARTY_TAX_PROFILE' as TAX_REPORTING_ENTITY_CODE
    FROM ZX_PARTY_TAX_PROFILE ThirdPartyTaxProfileEO,
    HZ_PARTIES PartyPEO,
    FND_LOOKUP_VALUES_VL LkupPartyUsage,
    FND_TERRITORIES_VL TerritoryPEO
    WHERE ThirdPartyTaxProfileEO.PARTY_ID = PartyPEO.PARTY_ID AND
    LkupPartyUsage.LOOKUP_CODE = decode(ThirdPartyTaxProfileEO.CUSTOMER_FLAG,
    'Y',decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'SC',
    'C'),
    decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'S',
    NULL)
    ) AND
    PartyPEO.COUNTRY = TerritoryPEO.Territory_Code (+) AND
    LkupPartyUsage.LOOKUP_TYPE = 'ZX_TP_PARTY_USAGE'
    ORDER BY UPPER(PARTY_FULL_NAME)) QRSLT WHERE UPPER(PARTY_NAME) IS NOT
    NULL
    Any help will be appreciated

    You can rewrite your where clause to not use decode or case statements e.g. this:
      AND LkupPartyUsage.LOOKUP_CODE = DECODE( ThirdPartyTaxProfileEO.CUSTOMER_FLAG
                                , 'Y', DECODE( ThirdPartyTaxProfileEO.SUPPLIER_FLAG, 'Y', 'SC', 'C' )
                                     , DECODE( ThirdPartyTaxProfileEO.SUPPLIER_FLAG, 'Y', 'S', NULL ) )
                                     )can be rewritten to this:
    and (
          ( ThirdPartyTaxProfileEO.CUSTOMER_FLAG = 'Y'  AND
              ((ThirdPartyTaxProfileEO.SUPPLIER_FLAG = 'Y' AND LkupPartyUsage.LOOKUP_CODE = 'SC') or
                ThirdPartyTaxProfileEO.SUPPLIER_FLAG != 'Y' AND LkupPartyUsage.LOOKUP_CODE = 'C')) or
          ( ThirdPartyTaxProfileEO.CUSTOMER_FLAG != 'Y'  AND
              ((ThirdPartyTaxProfileEO.SUPPLIER_FLAG = 'Y' AND LkupPartyUsage.LOOKUP_CODE = 'S') or
                ThirdPartyTaxProfileEO.SUPPLIER_FLAG != 'Y' AND LkupPartyUsage.LOOKUP_CODE is null))
        )It's not as sussinct, but it avoids the use of functions that could be preventing the optimiser from using an index.

  • How to use index when use analytic functions?

    Oracle 11gR2, I have a an indexed snapshot log table (sequence$$ and PK indexed), and I use a query to access it...
    query looks like:
    SELECT "M_ROW$$", "SNAPTIME$$", "DMLTYPE$$", "OLD_NEW$$", "CHANGE_VECTOR$$", "SEQUENCE$$", "ID", "SITEID", "WEBPAGEID", "WEBFOLDERID"
    FROM mlog$_table1
    WHERE dmltype$$ = 'D'
    AND sequence$$ IN
    (SELECT DISTINCT
    LAST_VALUE (sequence$$)
    OVER (PARTITION BY siteid ORDER BY siteid)
    FROM mlog$_table1);
    how could I access mlog$_table1
    explain plan looks like:
    Plan
    SELECT STATEMENT ALL_ROWSCost: 53 Bytes: 605.864 Cardinality: 1.736                          
         6 HASH JOIN Cost: 53 Bytes: 605.864 Cardinality: 1.736                     
              4 VIEW VIEW SYS.VW_NSO_1 Cost: 28 Bytes: 22.555 Cardinality: 1.735                
                   3 HASH UNIQUE Cost: 28 Bytes: 45.110 Cardinality: 1.735           
                        2 WINDOW SORT Cost: 28 Bytes: 45.110 Cardinality: 1.735      
                             1 TABLE ACCESS FULL TABLE BONGO.MLOG$_PDSI1 Cost: 25 Bytes: 45.110 Cardinality: 1.735
              5 TABLE ACCESS FULL TABLE BONGO.MLOG$_PDSI1 Cost: 25 Bytes: 582.960 Cardinality: 1.735

    ok, I think I feel like a newbie :)
    explain plan for your query is:
    Plan
    SELECT STATEMENT ALL_ROWSCost: 22,1 Bytes: 416,678 Cardinality: 2,654           
         2 SORT GROUP BY Cost: 22,1 Bytes: 416,678 Cardinality: 2,654      
              1 TABLE ACCESS FULL TABLE IBIS.MLOG$_PARTIJA Cost: 22,098 Bytes: 416,678 Cardinality: 2,654
    but it runs for about 3-4 sec..
    1st query:
    create or replace view x as
    select * from mlog$_partija v
    where not (DMLTYPE$$='D' and update_type=2)
    and sequence$$=(select max(sequence$$) from mlog$_partija t
    where t.par_sifpar=v.par_sifpar);
    runs about 17 sec...
    wich is expected since there's a max in subselect...
    but, it's explain plan is:
    Plan
    SELECT STATEMENT ALL_ROWSCost: 108,957 Bytes: 1,84 Cardinality: 1                     
         5 HASH JOIN Cost: 108,957 Bytes: 1,84 Cardinality: 1                
              3 VIEW VIEW SYS.VW_SQ_1 Cost: 22,564 Bytes: 68.634.228 Cardinality: 2.639.778           
                   2 HASH GROUP BY Cost: 22,564 Bytes: 68.634.228 Cardinality: 2.639.778      
                        1 TABLE ACCESS FULL TABLE IBIS.MLOG$_PARTIJA Cost: 22,05 Bytes: 68.634.228 Cardinality: 2.639.778
              4 TABLE ACCESS FULL TABLE IBIS.MLOG$_PARTIJA Cost: 22,145 Bytes: 4.788.557.292 Cardinality: 2.639.778           
    but, I made a third solution wich is something like:
    create table mlog_table1_last as
    select siteid, max(sequence$$) max_seq from mlog$_table1 group by siteid
    I run a query on that temp table:
    select * from mlog$_table1 v
    where not (DMLTYPE$$='D' and update_type=2)
    and sequence$$=(select max_seq from mlog_table1_last t
    where t.siteid=v.siteid);
    it's explain plan is bad:
    Plan
    SELECT STATEMENT ALL_ROWSCost: 2.588.886 Bytes: 1,814 Cardinality: 1           
         3 FILTER      
              1 TABLE ACCESS FULL TABLE IBIS.MLOG$_PARTIJA Cost: 22,148 Bytes: 4.788.557.292 Cardinality: 2.639.778
              2 INDEX RANGE SCAN INDEX IBIS.MLOG_PARIJA_LAST_NDX2 Cost: 1 Bytes: 111,02 Cardinality: 4,27
    but it runs for 1-2 sec..
    why?

  • How to use index in a view?

    Hi!
    I have a view created of the following structure:
    create or replace view v as
      select col1, col2
      from a
    union all
      select col1, col2
      from bwhere both tables a and b have indexes on col1 - named i1 and i2 respectively.
    While using the view v I want to ensure that I use the indices defined to access data. How can I achieve that by means of optimizer hints? (or by means of anything else).
    Any feedback is appreciated. Thanks.

    Okay, here's what I have to deal with:
    For some reasons (out of my control) I have to use an Oracle Report*Writer 1.0 to present data from Oracle 9i DB.
    My simple (one query) report is running too slowly. It takes unlimited time to complete (at least more than 1,5 hour). But when I pull out the SQL query executed by the Report*Writer's session (using the tool 'PL/SQL Developer') and rerun it in the Developer it works just in 10sec. And I wonder why?
    At the moment I want to somehow manipulate execution plan (without using outlines and in fact without appropriate tools as have no access to OS (i.e. to take actual trace files from there))
    That's why I ask if I can somehow make sure that the Server uses indices while processing the query.

  • How to use indexes correctly in oracle

    Hi guys
    on one table i have indexes on 3 columns in the following order
    a
    b
    c
    When i m writing a select statement in my where clause what should be the order? like
    where
    a='some value' and
    b='some value' and
    c='some value';
    or in reverse order like this
    c='some value' and
    b='some value' and
    a='some value';
    please let me know.
    Thanks

    If you have an index on a,b,c the difference in performance can be on the index order.
    If column "a" has only 2 unique values then the sub values of the index only has 50% of the remaining values, the cost optimizer on Oracle will probably skip the index as an index scan of 50% is slower than a full table scan.
    If a has 100 unique values then the remaining search is only on 1% of the values so is likely to be used.
    As with any optimisation try using
    explain plan for selec x,y,z from a_table
    from where
    a='some value' and
    b='some value' and
    c='some value'
    If the index is not being used firstly try
    analyze table estimate statistics
    sample 10 percent
    for all indexes
    for all indexed columns;
    and failing than try different orders in acceptance environment.

  • How to use index of Oracle Table in EJB??

    Hello I have a Table Department and it's index on Dpt_Name column.
    I have created ejb - cmp in OC4J for Department Table.
    I am getting all the data but it is not in index on department, Where I have to specify index of table in Oc4j.
    Reply appriciated.
    Rajiv

    Rajive,
    An index is used automatically by the Database for faster retrieval of data. The query optimizer in the database determines whether to use an index and which index to use for a SQL statement and you don't have to specify the index in OC4J.
    If you have an index on deptname, then the index will be used when the SQL has a where clause like "where deptname = 'Personal' " or
    "where deptname like 'P%' ", etc. In case of CMP, if you have a finder method called findByDeptName and then this index will be used.
    For details on deciding on your indexing strategies please look at http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96590/adg06idx.htm#11977
    regards
    Debu Panda
    oracle

  • How to use date column index

    Hi,
    Why is that I got different results for my queries?
    Note that emp_date is indexed, so i dont want to use
    a function to it.
    QUERY1(full table scan)
    SELECT COUNT(*) FROM EMP WHERE TRUNC(EMP_DATE)=TRUNC(SYSDATE-30); (RESULT=8,842)
    QUERY2
    SELECT COUNT(*) FROM EMP WHERE
    EMP_DATE >=(SYSDATE-30) and EMP_DATE < (SYSDATE-30); (RESULT=0)
    QUERY3
    SELECT COUNT(*) FROM EMP WHERE
    EMP_DATE BETWEEN TRUNC(SYSDATE-30) and TRUNC(SYSDATE-30); (RESULT=2,100)
    Please help me how to use indexed date column...

    > Why is that I got different results for my queries?
    Because your queries are different.
    1) This one selects all records on 20 october, regardless of their time component
    2) This one selects all records with an emp_date at least being 20 october 14:56:30 AND being smaller than 20 october 14:56:30. No record will ever satisfy this condition.
    3) This one selects all records on 19./20 october at midnight 00:00:00
    Please see this example:
    SQL> create table myemp (emp_date)
      2  as
      3   select trunc(sysdate) - 30 +
      4          case
      5          when level <= 2100 then 0
      6          when level <= 8842 then dbms_random.value(1,86399)/86400
      7          else 2
      8          end
      9     from dual
    10  connect by level <= 100000
    11  /
    Tabel is aangemaakt.
    SQL> create index i1 on myemp(emp_date)
      2  /
    Index is aangemaakt.
    SQL> exec dbms_stats.gather_table_stats(user,'myemp',cascade=>true)
    PL/SQL-procedure is geslaagd.
    SQL> set autotrace on explain
    SQL> select count(*) from myemp where trunc(emp_date)=trunc(sysdate-30)
      2  /
                                  COUNT(*)
                                      8842
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=88 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (FULL) OF 'MYEMP' (Cost=88 Card=1000 Bytes=
              8000)
    SQL> select count(*) from myemp where
      2  emp_date >=(sysdate-30) and emp_date < (sysdate-30)
      3  /
                                  COUNT(*)
                                         0
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)
    SQL> select count(*) from myemp where
      2  emp_date between trunc(sysdate-30) and trunc(sysdate-30)
      3  /
                                  COUNT(*)
                                      2100
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)
    > Please help me how to use indexed date column...
    Use this query instead:
    SQL> select count(*)
      2    from myemp
      3   where emp_date between trunc(sysdate)-30 and trunc(sysdate)-29 - interval '1' second
      4  /
                                  COUNT(*)
                                      8842
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)Regards,
    Rob.

  • How to make sql to use index/make to query to perform better

    Hi,
    I have 2 sql query which results the same.
    But both has difference in SQL trace.
    create table test_table
    (u_id number(10),
    u_no number(4),
    s_id number(10),
    s_no number(4),
    o_id number(10),
    o_no number(4),
    constraint pk_test primary key(u_id, u_no));
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030301, 1, 1001, 1, 2001, 1);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030302, 1, 1001, 1, 2001, 2);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030303, 1, 1001, 1, 2001, 3);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030304, 1, 1001, 1, 2001, 4);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030305, 1, 1002, 1, 1001, 2);
    insert into test_table(u_id, u_no, s_id, s_no, o_id, o_no)
    values (2007030306, 1, 1002, 1, 1002, 1);
    commit;
    CREATE INDEX idx_test_s_id ON test_table(s_id, s_no);
    set autotrace on
    select s_id, s_no, o_id, o_no
    from test_table
    where s_id <> o_id
    and s_no <> o_no
    union all
    select o_id, o_no, s_id, s_no
    from test_table
    where s_id <> o_id
    and s_no <> o_no;
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    3 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    Statistics
    223 recursive calls
    2 db block gets
    84 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    508 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    5 sorts (memory)
    0 sorts (disk)
    8 rows processed
    -- i didnt understand why the above query is not using the index idx_test_s_id.
    -- But still it is faster
    select s_id, s_no, o_id, o_no
    from test_table
    where (u_id, u_no) in
    (select u_id, u_no from test_table
    minus
    select u_id, u_no from test_table
    where s_id = o_id
    or s_no = o_no)
    union all
    select o_id, o_no, s_id, s_no
    from test_table
    where (u_id, u_no) in
    (select u_id, u_no from test_table
    minus
    select u_id, u_no from test_table
    where s_id = o_id
    or s_no = o_no);
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=16 Card=2 Bytes=156)
    1 0 UNION-ALL
    2 1 FILTER
    3 2 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=6 Bytes=468)
    4 2 MINUS
    5 4 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=26)
    6 4 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_TABLE' (TABLE) (Cost=2 Card=1 Bytes=78)
    7 6 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1)
    8 1 FILTER
    9 8 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=6 Bytes=468)
    10 8 MINUS
    11 10 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=26)
    12 10 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_TABLE' (TABLE) (Cost=2 Card=1 Bytes=78)
    13 12 INDEX (UNIQUE SCAN) OF 'PK_TEST' (INDEX (UNIQUE)) (Cost=1 Card=1)
    Statistics
    53 recursive calls
    8 db block gets
    187 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    508 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    4 sorts (memory)
    0 sorts (disk)
    8 rows processed
    -- The above query is using index PK_TEST. But still it has FULL SCAN to the
    -- table two times it has the more cost.
    1st query --> SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=8 Bytes=416)
    2nd query --> SELECT STATEMENT Optimizer=ALL_ROWS (Cost=16 Card=2 Bytes=156)
    My queries are:
    1) performance wise which query is better?
    2) how do i make the 1st query to use an index
    3) is there any other method to get the same result by using any index
    Appreciate your immediate help.
    Best regards
    Muthu

    Hi William
    Nice...it works.. I have added "o_id" and "o_no" are in part of the index
    and now the query uses the index
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    3 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    Statistics
    7 recursive calls
    0 db block gets
    21 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    507 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    8 rows processed
    But my questions are:
    1) In a where clause, if "<>" condition is used, then, whether the system will use the index. Because I have observed in several situations even though the column in where clause is indexed, since the where condition is "like" or "is null/is not null"
    then the index is not used. Same as like this, i assumed, if we use <> then indexes will not be used. Is it true?
    2) Now, after adding "o_id" and "o_no" columns to the index, the Execution plan is:
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    3 1 INDEX (FULL SCAN) OF 'IDX_TEST_S_ID' (INDEX) (Cost=1 Card=4 Bytes=208)
    Before it was :
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=8 Bytes=416)
    1 0 UNION-ALL
    2 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    3 1 TABLE ACCESS (FULL) OF 'TEST_TABLE' (TABLE) (Cost=3 Card=4 Bytes=208)
    Difference only in Cost (reduced), not in Card, Bytes.
    Can you explain, how can i decide which makes the performace better (Cost / Card / Bytes). Full Scan / Range Scan?
    On statistics also:
    Before:
    Statistics
    52 recursive calls
    0 db block gets
    43 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    507 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    8 rows processed
    After:
    Statistics
    7 recursive calls
    0 db block gets
    21 consistent gets
    0 physical reads
    0 redo size
    701 bytes sent via SQL*Net to client
    507 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    8 rows processed
    Difference in recursive calls & consistent gets.
    Which one shows the query with better performance?
    Please explain..
    Regards
    Muthu

  • How can i use index in select query.. facing problem with the select query.

    Hi Friends,
    I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
    Here is the query:
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelat LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelatrprctr
        WHERE rldnr  = c_telstra_accounting
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          And rzzlstar in r_lstar                            
          AND rpmax  = c_max_period.
    There are 5 indices present for Table ZTFTELAT.
    Indices of ZTFTELAT:
      Name   Description                                               
      0        Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)                                          
      005    Profit (RCLNT,RPRCTR)
      1        Ledger, company code, account (RLDNR,RBUKRS, RACCT)                                
      2        Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)                           
      3        Account, cost center (RACCT,RCNTR)                                        
      4        RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR                        
      Z01    Activity Type, Account (RZZLSTAR,RACCT)                                        
      Z02    RYEAR-RBUKRS- RZZZBER-RLDNR       
    Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
    Thanks in advance.

    Hi Shiva,
    I am using two more select queries with the same manner ....
    here are the other two select query :
    ***************1************************
    SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelpt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelptrprctr
        WHERE rldnr  = c_telstra_projects
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar             
          AND rpmax  = c_max_period.
    and the second one is
    *************************2************************
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelnt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelntrprctr
        WHERE rldnr  = c_telstra_networks
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar                              
          AND rpmax  = c_max_period.
    for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables.  if i will not use it will delete all the data fetched earlier.
    Thanks on advanced......
    Sourabh

  • How to use the index method for pathpoints object in illustrator through javascripts

    hii...
    am using Illustrator CS2 using javascripts...
    how to use the index method for pathpoints object in illustrator through javascripts..

    Hi, what are you trying to do with path points?
    CarlosCanto

  • How is it possible to use Index Seek for LIKE %search-string% case?

    Hello,
    I have the following SP:
    CREATE PROCEDURE dbo.USP_SAMPLE_PROCEDURE(@Beginning nvarchar(15))
    AS
    SELECT * FROM HumanResources.Employee
    WHERE NationalIDNumber LIKE @Beginning + N'%';
    GO
    If I run the sp first time with param: N'94', then the following plan is generated and added to the cache:
    SQL Server "sniffs" the input value (94) when compiling the query. So for this param using Index Seek for AK_Employee_NationalIDNumber index will be the best option. On the other hand, the query plan should be generic enough to be able to handle
    any values specified in the @Beginning param.
    If I call the sp with @Beginning =N'%94':
    EXEC dbo.USP_SAMPLE_PROCEDURE N'%94'
    I see the same execution plan as above. The question is how is it possible to reuse this execution plan in this case? To be more precise, how
    Index Seek can be used in case LIKE %search-string% case. I expected that
    ONLY Index Scan operation can be used here.
    Alexey

    The key is that the index seek operator includes both seek (greater than and less than) and a predicate (LIKE).  With the leading wildcard, the seek is effectively returning all rows just like a scan and the filter returns only rows matching
    the LIKE expression.
    Do you want to say that in case of leading wildcard, expressions Expr1007 and Expr1008 (see image below) calculated such a way that
    Seek Predicates retrieve all rows from the index. And only
    Predicate does the real job by taking only rows matching the Like expression? If this is the case, then it explains how
    Index Seek can be used to resolve such queries: LIKE N'%94'.
    However, it leads me to another question: Since
    Index Seek in
    this particular case scans
    all the rows, what is the difference between
    Index Seek and Index Scan?
    According to
    MSDN:
    The Index Seek operator uses the seeking ability of indexes to retrieve rows from a nonclustered index.
    The storage engine uses the index to process
    only those rows that satisfy the SEEK:() predicate. It optionally may include a WHERE:() predicate, which the storage engine will evaluate against all rows that satisfy the SEEK:() predicate (it does not use the indexes to do this).
    The Index Scan operator retrieves
    all rows from the nonclustered index specified in the Argument column. If an optional WHERE:() predicate appears in the Argument column, only those rows that satisfy the predicate are returned.
    It seems like Index Scan is a special case of Index Seek,
    which means that when we see Index Seek in the execution plan, it does NOT mean that storage engine does NOT scan all rows. Right?
    Alexey

  • How to check small table scan full table scan if we  will use index  in where clause.

    How to check small table scan full table scan if i will use index column in where clause.
    Is there example link there i can  test small table scan full table  if index is used in where clause.

    Use explain plan on your statement or set autotrace traceonly in your SQL*Plus session followed by the SQL you are testing.
    For example
    SQL> set autotrace traceonly
    SQL> select *
      2  from XXX
      3  where id='fga';
    no rows selected
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=13 Card=1 Bytes=16
              5)
       1    0   PARTITION RANGE (ALL) (Cost=13 Card=1 Bytes=165)
       2    1     TABLE ACCESS (FULL) OF 'XXX' (TABLE) (Cost=13 Card
              =1 Bytes=165)
    Statistics
              1  recursive calls
              0  db block gets
           1561  consistent gets
            540  physical reads
              0  redo size
           1864  bytes sent via SQL*Net to client
            333  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              0  rows processed

  • How to get substring from string using index?

    hi,
    here i am having string ,
    i want the pullareddy from below line ,
    i know how to get from substring.
    but i want to get the above using "index",
    can any help how to do it?
    String str1="janapana,pullareddy, in malaysia";
    jpullareddy

    get the start index with indexAt("pullareddy")
    get the end index with adding the length of the word to the start
    get the char[] of str1 with toCharArray()
    make a new string with the chars from start to end index.

Maybe you are looking for

  • Screen turns bright yellow & green curser turns into a large yellow square.

    When I play any type of 3d game, such as world of warcraft my screen turns bright yellow and green. The mouse cursor turns into a large yellow square. Then it will make squiggly patterns across the screen in these colors, Almost like a argyle pattern

  • Activating iPhone service without a computer

    Okay, so here's the deal: I bought my iPhone 3G back in October 2008. I cancelled my service due to being unable to make payments. I would like to reactivate it again. Only problem is that I have no regular access to a computer or my own personal iTu

  • SQL command not properly ended

    I am writting a procedure, I declare a cursor, the code like: CREATE or replace procedure printloanbooklist(cardno in integer) as cursor cur_loanbooklist is select book_loans.book_id bookid, title , date_due, book_loans.branch_id branchid, author_nam

  • Mighty Mouse Woes

    Anybody know why (i.e., how to fix) a Mighty Mouse that worked fine for a month, now will not scroll? Scrolls up sometimes, never down, never sideways. Battery is fine.

  • Data for XBLNR

    Hi Gurus,    Hope you are all doing good. I have performed LO extraction. How to get data   for the field "XBLNR". I am unable to identify the datasource for this. Points will   be assigned.   Regards,   Sunitha.