Force the use of the index without advice

Dear all,

I'm a newbie in the world of oracle.

I HAD POSTED THIS SAME QUESTION IN SQL AND PLSQL CATEGORY, but thought that I had posted in a wrong category, so I post the same question again here.

Recently my boss asked me a question about the use of the index.

He wants to force the index to use if the optimizer chooses not to use it.

But limitattion is this boat reach the query or the code because it is taken directly by an application that we can not change the code.

So how is - a can force a query to use index without giving advice.

It should be for a particular query, it should not apply for all indexes in the database.

I know a parameter "OPTIMIZER_INDEX_COST_ADJ. If you set this parameter correctly, you can force the optimizer to use index. But it has its own limitations.

So I want an alternative to this option which can only be applied to a particular query that is run without the use of indicators.

Because this is my first thread, sorry if I made any mistake by posting the question

Thank you all in advance

Kind regards
Navin Bandi

Hello

Have you tried the oracle outlines.

Concerning
Anurag

Tags: Database

Similar Questions

  • To force the index

    Hello

    My DB is 10.2.0.4

    I have a HISTORY table that has 4 million documents.
    I have a query which gives 15 lines out of it.
    Index is exactly on the same columns as the where clause.
    My = ALL_ROWS optimizer_mode

    I had read "complete analyses are NOT ALWAYS evil, indexes are NOT ALWAYS good.
    But is it possible to force the query to use the indexes here?
     
    CREATE INDEX history_idx3
      ON history (
        ACCNR,
        ACCERGNR,
        CUSTNR
      )
      STORAGE (
        INITIAL  241664 K
      )
    /
    
    
    SQL> SELECT * FROM HISTORY
    WHERE ACCNR = 1500003
    AND ACCERGNR = 0
    AND CUSTNR = 230530  2    3    4  ;
    
    15 ROWS SELECTED.
    
    ELAPSED: 00:03:41.00
    
    EXECUTION PLAN
    ----------------------------------------------------------
    PLAN HASH VALUE: 3565408272
    
    ------------------------------------------------------------------------------
    | ID  | OPERATION         | NAME     | ROWS  | BYTES | COST (%CPU)| TIME     |
    ------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |          |     1 |   200 | 93050   (2)| 00:18:37 |
    |*  1 |  TABLE ACCESS FULL| HISTORY |     1 |   200 | 93050   (2)| 00:18:37 |
    ------------------------------------------------------------------------------
    
    PREDICATE INFORMATION (IDENTIFIED BY OPERATION ID):
    ---------------------------------------------------
    
       1 - FILTER("CUSTNR"=230530 AND "ACCERGNR"=0 AND
                  TO_NUMBER("ACCNR")=1500003)
    
    
    STATISTICS
    ----------------------------------------------------------
              1  RECURSIVE CALLS
              0  DB BLOCK GETS
         420095  CONSISTENT GETS
         418614  PHYSICAL READS
              0  REDO SIZE
           6266  BYTES SENT VIA SQL*NET TO CLIENT
            492  BYTES RECEIVED VIA SQL*NET FROM CLIENT
              2  SQL*NET ROUNDTRIPS TO/FROM CLIENT
              0  SORTS (MEMORY)
              0  SORTS (DISK)
             15  ROWS PROCESSED

    seems to be ACCNR in the table BACKGROUND is defined as VARCHAR?
    If so, your index is ignored.

    Try this:

    SELECT * FROM HISTORY
    WHERE ACCNR = '1500003'
    AND ACCERGNR = 0
    AND CUSTNR = 230530                                                                                                                                                                                                                                                                                                                                                                                                        
    
  • Query is not using the index. (Included execution plan. TKPROF output not available)

    Hi all

    Version of DB: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

    Here is the description of the problem:
    (The statistics are up to date for all tables).

    The query below does not use the index on ACCOUNTS_LIVE (ID). (Unique index)
    SQL> explain plan for
      2  select txn.account_number,to_number(txn.amount_lcy) txn_amt,to_date(booking_date,'YYYYMMDD') TXN_DATE,
      3        sal.latest_sal,sal.sal_date,customer_name,employer_name,
      4       decode(COMMUNICATION_TYPE_1,'MOBILE',COMMUNICATION_NO_1,
      5            decode(COMMUNICATION_TYPE_2,'MOBILE',COMMUNICATION_NO_2)) mob,
      6       txn.CURRENCY, CHEQUE_NUMBER,trans_dets,trans_reference,target,teller_id,acc.category,acc.inactive_marker,
      7            acc.posting_restrict,cus.sector,cus.industry
      8  from coreadmin.Gtxn_dtl_v1 txn,
      9                     (select account_number,round(to_number(nvl(amount_lcy,0)),2) latest_sal,TXN_DATE sal_date,rr
     10                      from
     11                        (select to_date(booking_date,'YYYYMMDD') TXN_DATE,batch_id,account_number,amount_lcy
     12                             ,row_number() over (partition by account_number
     13                                                     order by to_date(booking_date,'YYYYMMDD') desc NULLS LAST,
     14                                                     batch_id desc nulls last) rr,
     15                                     CURRENCY, CHEQUE_NUMBER,trans_dets,trans_reference
     16                             from coreadmin.Gtxn_dtl_v1
     17                             where transaction_code in ('204','938')
     18                  and to_number(amount_lcy) > 0)
     19                             where rr = 1
     20                       ) sal,accounts_live acc,customers_live cus
     21  where to_date(booking_date,'YYYYMMDD') between to_date('030109','DDMMRR') and to_date('020209','DDMMRR')
     22  and txn.account_number = sal.account_number
     23  and txn.account_number = acc.id
     24  and txn.CUSTOMER_ID = cus.CUSTOMER_number
     25  and target in ('30','31','32')
     26  /
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT                                                                                                                                     
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 920245766                                                                                                                            
                                                                                                                                                          
    -----------------------------------------------------------------------------------------------------------                                           
    | Id  | Operation                        | Name           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |                                           
    -----------------------------------------------------------------------------------------------------------                                           
    |   0 | SELECT STATEMENT                 |                |   363M|   121G|       |   223K  (4)| 00:44:47 |                                           
    |*  1 |  HASH JOIN                       |                |   363M|   121G|  6232K|   223K  (4)| 00:44:47 |                                           
    |*  2 |   VIEW                           |                | 34453 |  5820K|       |   147K  (1)| 00:29:36 |                                           
    |*  3 |    WINDOW SORT PUSHED RANK       |                | 34453 |  1480K|  4072K|   147K  (1)| 00:29:36 |                                           
    |*  4 |     FILTER                       |                |       |       |       |            |          |                                           
    |   5 |      INLIST ITERATOR             |                |       |       |       |            |          |                                           
    |*  6 |       TABLE ACCESS BY INDEX ROWID| GTXN_DTL_V1    | 34453 |  1480K|       |   147K  (1)| 00:29:31 |                                           
    |*  7 |        INDEX RANGE SCAN          | IDX_TXN5       |   707K|       |       |  1815   (2)| 00:00:22 |                                           
    |*  8 |   HASH JOIN                      |                |   598K|   106M|    20M| 63724   (1)| 00:12:45 |                                           
    |*  9 |    MAT_VIEW ACCESS FULL          | CUSTOMERS_LIVE |   227K|    17M|       |  2239   (4)| 00:00:27 |                                           
    |* 10 |    HASH JOIN                     |                |   598K|    59M|  9504K| 57157   (1)| 00:11:26 |                                           
    |  11 |     MAT_VIEW ACCESS FULL         | ACCOUNTS_LIVE  |   249K|  6577K|       |  1832   (2)| 00:00:22 |                                           
    |* 12 |     TABLE ACCESS BY INDEX ROWID  | GTXN_DTL_V1    |   597K|    43M|       | 52319   (1)| 00:10:28 |                                           
    |* 13 |      INDEX RANGE SCAN            | IDX_TXN11_V1   |  1204K|       |       |  3931   (2)| 00:00:48 |                                           
    -----------------------------------------------------------------------------------------------------------                                           
                                                                                                                                                          
    Predicate Information (identified by operation id):                                                                                                   
    ---------------------------------------------------                                                                                                   
                                                                                                                                                          
       1 - access("TXN"."ACCOUNT_NUMBER"="ACCOUNT_NUMBER")                                                                                                
       2 - filter("RR"=1)                                                                                                                                 
       3 - filter(ROW_NUMBER() OVER ( PARTITION BY "ACCOUNT_NUMBER" ORDER BY                                                                              
                  TO_DATE("BOOKING_DATE",'YYYYMMDD') DESC  NULLS LAST,INTERNAL_FUNCTION("BATCH_ID") DESC  NULLS                                           
                  LAST)<=1)                                                                                                                               
       4 - filter(TO_DATE('030109','DDMMRR')<=TO_DATE('020209','DDMMRR'))                                                                                 
       6 - filter(TO_NUMBER("AMOUNT_LCY")>0)                                                                                                              
       7 - access("TRANSACTION_CODE"='204' OR "TRANSACTION_CODE"='938')                                                                                   
       8 - access("TXN"."CUSTOMER_ID"="CUS"."CUSTOMER_NUMBER")                                                                                            
       9 - filter("TARGET"='30' OR "TARGET"='31' OR "TARGET"='32')                                                                                        
      10 - access("TXN"."ACCOUNT_NUMBER"="ACC"."ID")                                                                                                      
      12 - filter("TXN"."CUSTOMER_ID" IS NOT NULL)                                                                                                        
      13 - access(TO_DATE("BOOKING_DATE",'YYYYMMDD')>=TO_DATE('030109','DDMMRR') AND                                                                      
                  TO_DATE("BOOKING_DATE",'YYYYMMDD')<=TO_DATE('020209','DDMMRR'))                                                                         
    
    38 rows selected.
    
    SQL> select index_name
      2  from dba_ind_columns
      3  where table_name = 'ACCOUNTS_LIVE'
      4  and column_name = 'ID';
    
    INDEX_NAME                                                                                                                                            
    ------------------------------                                                                                                                        
    IDX_ACCLIVE                                                                                                                                           
    Line 23 of the query uses accounts_live.id.

    11 the order ID explain plan shows that the index does not use.

    Please suggest.

    Thanks in advance,
    Jac

    What happens when you force the index by using hint and use the hash between txn and acc join?

    See you soon
    Sarma.

  • TIP, GOLD and the INDEX FUNCTION-ORIENTED

    RDBMS: 10.1.0.5.0

    I'm trying to force an index based on a function in a query with a condition OR .
    It seems that INDEX INDICATOR does not work if the query has an OR condition.

    I created a test case to describe the problem:
    create table tab1 (col1 VARCHAR2(300))
    
    ....load the table.......
    
     CREATE INDEX col1_IX ON tab1
       (
          my_FUNCTION(col1)
       )
       TABLESPACE USERS ;
    The plan of the explain for a simple query command is:
    select * from tab1 where my_FUNCTION(col1) = '+23452081'
    
    Plan hash value: 2179519467
     
    ---------------------------------------------------------------------------------------
    | Id  | Operation                   | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |         |   871 |   512K|     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| TAB1    |   871 |   512K|     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | COL1_IX |   348 |       |     1   (0)| 00:00:01 |
    ---------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       2 - access("my_FUNCTION"("COL1")='+23452081')
     
    Note
    -----
       - dynamic sampling used for this statement
    If the simple query has a CONDITION or:
    select * from tab1 where ( MY_FUNCTION(col1) = '+23452081' or col1       <> '')
    
    Plan hash value: 2211052296
     
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |  5183 |  3047K|    59  (31)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| TAB1 |  5183 |  3047K|    59  (31)| 00:00:01 |
    --------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       1 - filter("COL1"<>'' OR "MY_FUNCTION"("COL1")='+23452081')
     
    Note
    -----
       - dynamic sampling used for this statement
    I tried to force the index using the trick without success:
    select /*+ index(tab1 col1_IX) */ * from tab1 where ( MY_FUNCTION(col1) = '+23452081' or col1       <> '')
    
    Plan hash value: 2211052296
     
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |  5183 |  3047K|    59  (31)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| TAB1 |  5183 |  3047K|    59  (31)| 00:00:01 |
    --------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       1 - filter("COL1"<>'' OR "MY_FUNCTION"("COL1")='+23452081')
     
    Note
    -----
       - dynamic sampling used for this statement
    Can you help me?

    Published by: Dom Brooks on January 28, 2011 11:26

    Sorry too hasty.

    If you have an index on COL1 and your predicate can use this index, then you might get a BITMAP CONVERSION.

    If you do not have an index on COL1 or you cannot use it, then you will do a FTS.

    Useful relevant info:

    Based on an index function are not used in the expansion of GOLD in 10gR 1 (or beyond - restriction still documented in 11 GR 2)

    See here:
    http://download.Oracle.com/docs/CD/B14117_01/AppDev.101/b10795/adfns_in.htm#1006464

    Dion Cho spoke here:
    http://dioncho.WordPress.com/2009/07/31/function-based-index-and-or-expansion/

  • How we force a query to use transparently a hint, even if the index is not given in the query as a query rewriting.

    How we force a query to use transparently a hint, even if the index is not given in the query as a query rewriting.

    For example:

    If the user runs a query select deptno, avg (sal) from emp group by deptno;

    We want the optimizer to use a hint of result_cache with this request, and it should be transparent to the user.

    Query should be rewritten to seamlessly

    Select / * + result_cache * / deptno, avg (sal)

    WCP

    Group of deptno;

    How can this feature we make? Please advice.

    I checked the possibility of SPM and contours, but it is not clear if this rewrite is possible here.

    Thank you and best regards,

    Vikas Krishna

    Surely dbms_advanced_rewrite is designed for this situation?

  • SDO_NN cannot be assessed without using the index

    Hello
    I'll try to find more close neighbours of a point using two tables (grafo_ped_links & haltestellen) and I fail miserably quiet.

    Select h.desc_i, grafo_ped_links h.numpal g, haltestellen h where (g.geometry, h.geometry) sdo_nn = 'true' and g.start_node_id = 355 and rownum < = 5
    *
    ERROR on line 1:
    ORA-13249: SDO_NN cannot be assessed without using the index
    ORA-06512: at the 'MDSYS. MD", line 1723
    ORA-06512: at the 'MDSYS. MDERR", line 17
    ORA-06512: at the 'MDSYS. PRVT_IDX', line 49

    But I am able to find the nearest neighbor on individual tables (singularly) without any problem. I'm even able to find a WITHIN_DISTANCE using two tables (below the sql statement).

    Select h.numpal from grafo_ped_links g, haltestellen h where SDO_WITHIN_DISTANCE (h.geometry, g.geometry, 'DISTANCE = 0.5 UNIT = KM') = 'TRUE' and g.start_node_id = 355;

    NUMPAL
    ----------
    5122
    5103
    5102
    5120
    5100
    5301
    5302
    5303

    I even dropped the indexes of the two tables and recreated them again. I read somewhere that the problem could be due to a lack of advice, so I tried the following and I still get the same error.


    Select / * + LEADING (g) INDEX (h haltestellen_ridx) * / h.desc_i, h.numpal
    of grafo_ped_links g, h haltestellen
    where (g.geometry, h.geometry) sdo_nn = 'true' and g.start_node_id = 355 and rownum < = 5

    Select / * + INDEX (h haltestellen_ridx) NO_INDEX (g grafo_ped_links_ridx) * / h.desc_i, h.numpal
    of grafo_ped_links g, h haltestellen
    where (g.geometry, h.geometry) sdo_nn = 'true' and g.start_node_id = 355 and rownum < = 5

    Select / * + USE_NL (h, g) VALUE * / h.desc_i, h.numpal
    of grafo_ped_links g, h haltestellen
    where sdo_nn (g.geometry, h.geometry, 'sdo_num_res = 5', 1) = 'true' and g.start_node_id = 355 and rownum < = 5


    Anyone can please, show me the way, or give a hint. I use oracle spatial 11g.

    Thank you!
    Cook

    Published by: user611283 on December 30, 2009 06:11

    It should be 'TRUE '.

    Select h.desc_i, grafo_ped_links h.numpal g, haltestellen h where (h.geometry, g.geometry) sdo_nn = 'TRUE' and g.start_node_id = 355 and rownum<=>

  • SDO_NN cannot be assessed without using the index when put inside subquery

    Hi all

    I met a problem when you use the function sdo_nn to find the nearest neighbor. Here is my scenario:

    _ I have 2 customer and store tables.

    Customer table _ a client_ID and a 2D sdo_geom point

    _ Store table has store_ID and a 2D polygon sdo_geom.

    In the beginning, I have this query to find the nearest store to each customer as below:

    Select s.STORE_ID, c.CLIENT_ID

    store customer, s c

    where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE";

    _It works as expected when it returns a table showing the nearest store each customer.

    _Now I want to count the number of customers who have the same nearest store:

    Select / * + INDEX (store store_spatial_idx, client_spatial_idx client) * / count (nearest_store. CLIENT_ID)
    from (select s.STORE_ID, c.CLIENT_ID
    store customer, s c
    where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE") nearest_store
    Group of nearest_store. STORE_ID;

    This query generates the following error:

    Error report-
    SQL error: ORA-13249: SDO_NN cannot be assessed without using the index
    ORA-06512: at the 'MDSYS. MD", line 1723
    ORA-06512: at the 'MDSYS. MDERR", line 17
    ORA-06512: at the 'MDSYS. PRVT_IDX', line 9
    13249 00000 - '%s '.

    I'm pretty new to spatial databases and hope get help to go further. Thank you in advance!

    Hello Pinball,

    Oracle space tends to be a quite complex with many variables and moving parts.  We chatted about the group to a sort of FAQ or guidelines to help people like you submit questions that actually answers.  First of all, you really have to tell us the version of Oracle you are using.  Particularly the problems involving the optimizer, version down to the exact defined patch number is a good idea.  Secondly, you took the time to submit the question so I guess you want a response.  If you really want to see the answer and then providing an example is one of the most important things that you can do.  I'm going to do here for you, but in general people on this forum come and go and are often pushed into lurkitude, so if you want the coax to provide you with an example of work is the key.

    DROP TABLE store1 PURGE;
    CREATE TABLE store1(
        store_id INTEGER NOT NULL
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(store_id)
    );
    
    DROP TABLE client2 PURGE;
    CREATE TABLE client2(
        client_id INTEGER NOT NULL
       ,shape    MDSYS.SDO_GEOMETRY
       ,PRIMARY KEY(client_id)
    );
    
    CREATE OR REPLACE PROCEDURE seeder(
        p_client_count IN NUMBER
       ,p_store_count IN NUMBER
    )
    AS
      sdo_foo MDSYS.SDO_GEOMETRY;
      int_counter NUMBER;
      FUNCTION random_point
      RETURN MDSYS.SDO_GEOMETRY
      AS
          num_x1 NUMBER;
          num_y1 NUMBER;
    
      BEGIN
          num_x1 := dbms_random.value(-179,179);
          num_y1 := dbms_random.value(-89,89);
    
          RETURN MDSYS.SDO_GEOMETRY(
              2001
             ,8265
             ,MDSYS.SDO_POINT_TYPE(
                  num_x1
                 ,num_y1
                 ,NULL
              )
             ,NULL
             ,NULL
          );
    
      END random_point;
    
    BEGIN
      int_counter := 1;
      FOR i IN 1 .. p_client_count
      LOOP
          -- Create a client point
          sdo_foo := random_point();
          INSERT INTO client2
          VALUES (
              int_counter
             ,sdo_foo
          );
          int_counter := int_counter + 1;
    
      END LOOP;
    
      int_counter := 1;
      FOR i IN 1 .. p_store_count
      LOOP
          -- Create a store polygon of some kind
          sdo_foo := MDSYS.SDO_GEOM.SDO_ARC_DENSIFY(
              MDSYS.SDO_GEOM.SDO_BUFFER(
                  random_point()
                 ,5000
                 ,0.05
              )
             ,0.05
             ,'arc_tolerance=0.05'
          );
          INSERT INTO store1
          VALUES (
              int_counter
             ,sdo_foo
          );
          int_counter := int_counter + 1;
    
      END LOOP;
    
      COMMIT;
    
    END seeder;
    /
    
    BEGIN
      seeder(10000,200);
    END;
    /
    
    BEGIN
      INSERT INTO user_sdo_geom_metadata(
          table_name
         ,column_name
         ,diminfo
         ,srid
      ) VALUES (
          'STORE1'
         ,'SHAPE'
         ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
         ,8265
      );
    
      COMMIT;
    
    EXCEPTION
      WHEN OTHERS
      THEN
          NULL;
    
    END;
    /
    
    BEGIN
      INSERT INTO user_sdo_geom_metadata(
          table_name
         ,column_name
         ,diminfo
         ,srid
      ) VALUES (
          'CLIENT2'
         ,'SHAPE'
         ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05))
         ,8265
      );
    
      COMMIT;
    
    EXCEPTION
      WHEN OTHERS
      THEN
         NULL;
    
    END;
    /
    
    CREATE INDEX store1_spx ON store1
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    
    CREATE INDEX client2_spx ON client2
    (shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    NOPARALLEL;
    
    /* Works as expected */
    SELECT
    s.store_id
    ,c.client_id
    ,MDSYS.SDO_NN_DISTANCE(1)
    FROM
    store1 s
    ,client2 c
    WHERE
    MDSYS.SDO_NN(
        s.shape
       ,c.shape
       ,'sdo_num_res=1'
       ,1
    ) = 'TRUE';
    
    /* No worky? Works for me */
    SELECT
    ns.store_id
    ,COUNT(ns.client_id)
    FROM (
       SELECT
        s.store_id
       ,c.client_id
       FROM
        store1 s
       ,client2 c
       WHERE
       MDSYS.SDO_NN(
           s.shape
          ,c.shape
          ,'sdo_num_res=1'
          ,1
       ) = 'TRUE'
    ) ns
    GROUP BY
    ns.store_id
    ORDER BY
    ns.store_id;
    

    So I wrote this about 12 c (12.1.0.2.0) and everything works fine for me.  Then I moved back from 11 GR 2 (11.2.0.4.0) and of course, there are questions.  So I guess that you don't use flavor of 11g.  So at this point we can look at the docs and see for 11g, have you often need to specify which table is the head and that is the one that has the spatial index to use.
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11830/sdo_operat.htm#SPATL1032

    Its rather interesting that the optimizer of 12 c knows what you want, when I had to squint myself at your request and to play a little with the refining.  Note that SDO_NN is sensitive, because the geometry of the main table should come second in the operator.  I did not know that on the top of my head.

    
    SELECT
    /*+ LEADING(c) INDEX(s store1_spx)  */
     s.store_id
    ,c.client_id
    ,MDSYS.SDO_NN_DISTANCE(1)
    FROM
     store1 s
    ,client2 c
    WHERE
    MDSYS.SDO_NN(
        s.shape
       ,c.shape
       ,'sdo_num_res=1'
       ,1
    ) = 'TRUE';
    
    SELECT
     ns.store_id
    ,COUNT(ns.client_id)
    FROM (
       SELECT
       /*+ LEADING(c) INDEX(s store1_spx)  */
        s.store_id
       ,c.client_id
       ,MDSYS.SDO_NN_DISTANCE(1)
       FROM
        store1 s
       ,client2 c
       WHERE
       MDSYS.SDO_NN(
           s.shape
          ,c.shape
          ,'sdo_num_res=1'
          ,1
       ) = 'TRUE'
    ) ns
    GROUP BY
    ns.store_id
    ORDER BY
    ns.store_id;
    

    So I think that is your answer.  Give it a shot and see if this fits the Bill.  Of course, moving to 12 c would be useful for such things.  It would be interesting to collect more examples of this kind of space thing where 12 c is the answer. Also, would be nice if we could mark somehow this discussion as applying only to 11g and earlier versions.

    See you soon,.

    Paul

  • What is the right time to use the index with force?

    I have an EMPLOYEE table.  I join with the ROLE, and it has only about 200 distinct values on column EMPLOYEE. EMPLOYEE_TYPE_ID.

    Select / * + INDEX (an i_employee_type_id) * / b.SID as EMP_NAME, b.role_cd in the ROLE

    Of

    EMPLOYEE,

    B ROLE

    where

    a.EMPLOYEE_TYPE_ID = b.EMPLOYEE_TYPE_ID

    AND a.EFFECTIVE_END_TS > = systimestamp;

    Is it a good idea to use the index?  .. Or let the full table scan.

    SQL > select distinct EMPLOYEE_TYPE_ID of the EMPLOYEE;

    238 selected lines.

    If you don't know it will help not to use.

    Personally, I found several SQLs with index finger tips (written by programmers thinking index access is ALWAYS GOOD) end up harming performance. Oracle made a reading diluvium full table scan, single index reads as follows, according to the % of the returned array it is actually faster to do a full table scan. The optimizer did a great job to determine this.

    If you think there are cardinality estimation problems, and the optimizer expects a large number of lines when there are actually few being returned, in THIS case a suspicion was justified. Even so, in this case, I prefer that oracle manages the flag itself.

    You can do this by running the SQL tuning advisor. In fact, it will trigger the optimizer checks that the estimates are turned off and it will create a profile for you. (A profile is actually a stored set of advice that set the execution plan for you). If at the point where the underlying data changes significantly and profile ends up hurting performance, you do not need to touch the code like you would with manually added notes, you can just disable or delete the profile and let the optimizer re - analyze the statement.

    Concerning

    EDIT: In case of small tables, it is preferable to just cache the whole table in the POOL to KEEP and let oracle scan if necessary.

    Edit2: With the notable exception of index fast full scans, which are diluvium index readings. But they are only relevant when the request is quite satisfied by the index and has no need to visit the table.

  • SDO_NN giving ORA-13249: SDO_NN cannot be assessed without using the index

    Hi people,

    I do not understand why the SDO_NN gives ORA-13249 in circumstances.

    SQL > SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and title like '%' and rownum < 10;

    TITLE
    --------------------------------------------------------------------------------
    MultiPoint_305199
    LineString_691779
    MultiPolygon_180478
    MultiPolygon_358113
    MultiPolygon_53008
    MultiPolygon_249905
    MultiPolygon_204076
    MultiPolygon_636994
    MultiPoint_464514

    9 selected lines.

    SQL > SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and timestamp > = to_timestamp (January 6, 2011 ', ' dd/mm/yyyy') and rownum < 10;
    SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and timestamp > = to_timestamp (January 6, 2011 ', ' dd/mm/yyyy') and rownum < 10
    *
    ERROR on line 1:
    ORA-13249: SDO_NN cannot be assessed without using the index
    ORA-06512: at the 'MDSYS. MD", line 1723
    ORA-06512: at the 'MDSYS. MDERR", line 17
    ORA-06512: at the 'MDSYS. PRVT_IDX', line 49

    The spatial index is created with:
    CREATE the INDEX SlavaTest_geometry_idx_spatial ON SlavaTest (geometry) INDEXTYPE IS mdsys.spatial_index;

    'Title' and 'timestamp' columns have an index.

    Note the query comes from Hibernate and I can't change it's arbitrary.

    Slava2 wrote:
    What this means - there is a bug in Oracle?

    Well, it could probably be considered a, but [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#i78067] documentation on SDO_NN warns you:

    Documentation says:
    However, if the column in the WHERE clause predicate specifies a non-space column in the table for geometry1 with an associated index, make sure that this index is not used by specifying the NO_INDEX indicator for this index.

    See you soon,.
    Stefan

  • Using the index to extract data without filter predicate

    Hello

    does anyone have an explanation for the following scenario:

    I have a table T1 with an OID_IX index on column (object_id) - the table is a DEC dba_objects just to fill it with data.
    There are no other current index. The table and index are analysed.

    When I run the following query, the table is available in FULL (without using the index)

    SELECT OBJECT_ID FROM T1;

    SQL > select object_id from t1;

    485984 selected lines.

    Elapsed time: 00:00:01.76

    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 3617692013

    --------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 485K | 2372K | 1528 (1) | 00:00:19 |
    | 1. TABLE ACCESS FULL | T1 | 485K | 2372K | 1528 (1) | 00:00:19 |
    --------------------------------------------------------------------------


    Statistics
    ----------------------------------------------------------
    1 recursive calls
    0 db block Gets
    7396 gets coherent
    0 physical reads
    0 redo size
    2887158 bytes sent via SQL * Net to client
    5684 bytes received via SQL * Net from client
    487 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    485984 rows processed



    But if I add a predicate (even if it is useless in this case) the index is taken and that the query runs faster:



    JDBC@toekb > select object_id from t1 where object_id. = - 999;

    485960 selected lines.

    Elapsed time: 00:00:01.40

    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 3555700789

    -------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    -------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 485K | 2372K | 242 (3) | 00:00:03 |
    |* 1 | FULL RESTRICTED INDEX SCAN FAST | OID_IX | 485K | 2372K | 242 (3) | 00:00:03 |
    -------------------------------------------------------------------------------

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

    1 Filter ("OBJECT_ID" <>-(999))


    Statistics
    ----------------------------------------------------------
    1 recursive calls
    0 db block Gets
    1571 gets coherent
    0 physical reads
    0 redo size
    2766124 bytes sent via SQL * Net to client
    5684 bytes received via SQL * Net from client
    487 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    485960 rows processed


    Here is my setup:

    SQLsql-
    drop table t1 purge;
    create table t1 tablespace users in select * from dba_objects;
    Insert into t1 (select * from t1);
    commit;
    Insert into t1 (select * from t1);
    commit;
    Insert into t1 (select * from t1);
    commit;
    create index oid_ix on t1 (object_id) tablespace users;
    exec dbms_stats.gather_table_stats (null, 't1', cascade = > true, estimate_percent = > 100);
    SQLsql-

    In my case, the Table and the Index looks like this way:

    JDBC@toekb > select table_name, NUM_ROWS, BLOCKS, AVG_SPACE from user_tables;

    TABLE_NAME, NUM_ROWS BLOCKS AVG_SPACE
    =======================================
    485984 6944 T1 0

    Elapsed time: 00:00:00.11
    JDBC@toekb > select INDEX_NAME, BLEVEL, LEAF_BLOCKS, DISTINCT_KEYS, NUM_ROWS user_indexes.

    INDEX_NAME BLEVEL LEAF_BLOCKS DISTINCT_KEYS NUM_ROWS
    ===================================================
    2 1074 60745 485960 OID_IX

    Elapsed time: 00:00:00.07

    The table contains 7 times more than the index blocks!


    any answer welcome

    Best regards

    Published by: guenterp on August 12, 2010 14:44

    The column is not defined as NOT NULL, then there may be values that are not in the index (because the index does not include null values). The useless predicate implies NOT NULL, then the index may be used.

  • Force the VM to use the wired ethernet port instead of wireless

    Hello

    I use ver 9 workstation.  I have my host computer (win 7 64 bit) connected to our network of offices using the connection with wireless computers.

    I use a windows xp based virtual machine image that connects to devices of 3rd party via the ethernet port wired in Bridge mode.

    Is there a way to force the workstation on the use of only the cable connection and don't EVER try to connect via the wireless?

    At the moment I have to disable the wireless for the workstation to access cable port, if the without wire is activated, so you may not see anything on the wired port...

    It also causes headaches with ip address conflicts (3rd devices use the same IP range as our network of offices) if I don't have the VM running and wireless power.

    Any help or advice would be appreciated

    Tim

    Use the virtual network Editor to bind to the target adapter for VMnet0 and set the NIC of the virtual machine to use connected by a bridge.

  • Is there a way to load the Fax without the OS Indexing Services

    I have Windows XP Pro, indexing of fax services were not loaded with the operating system load.  Is there another way to get the components of Windows? I don't have the CD of the OS.

    I don't know what are the indexing of fax services, but if you try to install the XP Fax service and that you don't have an XP bootable installation CD authentic and installation asks for files that you do not have, I think I have all the required files to install the XP Fax Services brought together in a zip on my SkyDrive.

    The name of the ZIP on my SkyDrive file is:

    XPFax.zip

    You can download it and when you do, unzip it to a folder on your system and that you install the Services of Fax of XP and he needs a file (s), it points to the folder where you have unzipped the XPFax.zip file for installation to find the files, he needs.

    Here is the link to my SkyDrive and you can get the file you need here:

    https://SkyDrive.live.com/?CID=6a7e789cab1d6f39&ID=6A7E789CAB1D6F39! 311

    When you see the files available for download, you can not see the file extension (.exe, .dll, .cpl, .sys, .zip, etc.), but when download you them they will have the right extension.

    When you download the file (especially if you use Internet Explorer), when you get a chance to save the file, your browser is unable to save the file with an extension (by example, .exe, .dll, .cpl, .sys, .zip, etc) then you will need to manually add the extension appropriate to the file when you download the file before you save it.

    You can download the file without the extension, and then rename the file to add the appropriate extension.  You do not want to use a file called XPfax when the name of the file should really be called XPfax.zip (if the downloaded file has no extension, you will need to change the name of the file to add the appropriate extension to make it work.

  • Windows Photo Gallery. How can I change the settings in the Windows Photo Gallery to automatically open the image without going to the index first?

    Windows Photo Gallery.  How can I change the settings in the Windows Photo Gallery to automatically open the image without going to the index first?

    Additional information: there are 2 computers that I use on the first Gallery Photo of Windows will open the image and allow me to use the left and right buttons to scroll through the rest of the photos in the folder, that's what I want.

    On the 2nd computer when I open an image it will open the Windows Photo Gallery in an index with thumbnails of the displayed record.  How can I change so that it opens the same thing as the first computer?

    I did the following on both computers; Right-click on the image and select open with...--> choose the default program--> go--> Program Files, Windows Photo Gallery, but it will be open always differently on computer 2.

    Both computers use Windows Vista 32-bit.

    Thanks in advance.

    Australian salvation,

    This would happen if the file associations are corrupted on the computer, try method to set Photo Gallery Windows as the default program for opening files jpeg or png below image types.

    (a) open default programs by clicking the Start button, click default programs.

    (b) click on associate a type of file or Protocol with a program

    (c) in the following list of file protocol search jpeg and make sure that you have associated with the program that uses it and then check if it works.

    Change the programs that Windows uses by default

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-which-programs-Windows-uses-by-default

    I hope this helps!

    Halima S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • When I keyin information of track using Media Player, is this info inserted in the file itself, or only in the index Media Player?

    Original title: metadata key - music

    My question is actually very specific: when I keyin track using Media Player Info, is this info inserted in the file itself, or only in the index of Media Player? If I have to rebuild the indexes in the metadata file, the indexed fields are kept in?

    Only in the index of Media Player.  If you remove this file WMP (without actually deleting the computer/folder) and then read the file again, you would see that your changes have disappeared.

    To actually change the file, you will need a program known as ID3 Tag Editor.

  • The index used only when given Index indicator

    Hello

    Version of RDBMS - 11.2.0.3.0

    I have a situation where only when I use the Index indicator, index does is used.

    Use case: -.

    1. SELECT query on a table with about 100 KB of data.

    2. have the index on the column that is used in the WHERE clause of the SELECT query.

    CREATE TABLE him_entity (id NUMBER, him_val CHAR(1));
    
    
    INSERT INTO him_entity
    SELECT rownum,'1' FROM dual CONNECT BY level<=1000000;
    
    
    CREATE INDEX idx_him_val ON him_entity(him_val);
    
    
    
    
    
    

    Without using Index indicator, Explain plan: -.

    SELECT ID 
    FROM him_entity
    WHERE him_val='1';
    
    
    -----------------------------------------------------------------------------------
    | Id  | Operation         | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |               |  1000K|  4882K|   498   (5)| 00:00:06 |
    |*  1 |  TABLE ACCESS FULL| HIM_ENTITY    |  1000K|  4882K|   498   (5)| 00:00:06 |
    -----------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       1 - filter("HIM_VAL"='1')
    

    With the help of Index indicator, explain the plan: -.

    SELECT /*+ index(him_entity idx_him_val)*/ ID 
    FROM him_entity
    WHERE him_val='1';
    
    
    ---------------------------------------------------------------------------------------------
    | Id  | Operation                   | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |               |  1000K|  4882K|  3485   (1)| 00:00:42 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| HIM_ENTITY    |  1000K|  4882K|  3485   (1)| 00:00:42 |
    |*  2 |   INDEX RANGE SCAN          | IDX_HIM_VAL   |  1000K|       |  1824   (1)| 00:00:22 |
    ---------------------------------------------------------------------------------------------
    
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
    
       2 - access("HIM_VAL"='1')
    

    (1) could you explain why Index was not be picked up without indicator Index for help?

    (2) I gathered statistics for the table before running the query.

    (3) is it fine / safe to use the FIRST_ROWS hint instead of Index indicator?

    Thank you...

    1. SELECT THE ID
    2. OF him_entity
    3. WHERE him_val = '1';

    You select all the rows in the table.

    As your query will extract all lines then the optimal trajectory IS FULL TABLE SCAN instead of using INDEXES

    If we let you use less than 5% of table rows, and then using index can be an optimal trajectory to go for the record.

    1. SELECT / * + index (him_entity idx_him_val) * / ID
    2. OF him_entity
    3. WHERE him_val = '1';

    Your strength of indicator Index to fetch the file by using the index of the query

Maybe you are looking for

  • Updated for Firefox 36.0 now get Windows Security Alert

    Hello Updated for firefox 36.0 24/02/15Now to get a Windows security alertWindows Firewall has blocked some features of this program.Name: FirefoxPublisher: Mozilla CorporationPath: C:\program files (x 86) \mozilla firefox\firefox.exePrivate networks

  • page of coverage in the new firefox?

    I've been using Firefox for some time and love it. But before this new Firefox, I would like to know... The former "tiles" is kept in the new Firefox? the tiles are as a bookmark to a page displayed in a new empty tab. Here is a picture of what I'm t

  • Using labview, how do I access the card chip with the smart card reader?

    Hi all I read some of the 2006 post, it helped me some what but I'm still stuck.  I can communicate with the card reader SCR335 until getting the list of card reader.  When I use the winscard.dll to get the status of the card, I get '6' which means n

  • Caps lock and num lock keys lights don't light up

    Hello My caps lock and num lock keys lights don't light up when I turn the plugs or NumLock on, I recently contacted Microsoft Tech support, they told me to contact my HP manufacturing and it's a laptop, they did ' t really gives me a lot of support,

  • Redirecting to youtube video in application does not

    Player p = null;Try{p = Manager.createPlayer (url);p.Realize ();}catch (System.Exception e){e.printStackTrace ();}VideoControl vc = (VideoControl) p.getControl ("javax.microedition.media.control.VideoControl");C field (Field) = vc.initDisplayMode (Vi