SQL, not not using index on a partitioned table

I partitioned table that has rows over 15 million
I have a query that selects records based on the flag = 1
There are only 2 possible values for the flag, it is 0 or 1
I tried two index and local bitmap index on this field.
The query always uses full table scan
any suggestions?

Assuming that you have an index

CREATE INDEX idx_maint_chg_flag
   ON a_maintenance( CASE WHEN record_changed = 1 THEN 1 ELSE NULL END);

your request would be

SELECT *
  FROM a_maintenance
 WHERE (CASE WHEN record_changed = 1 THEN 1 ELSE NULL END) = 1

Of course, it may be easier to follow if you create a function is_record_changed

CREATE FUNCTION is_record_changed( p_flag NUMBER )
  RETURN NUMBER
IS
BEGIN
  IF( p_flag = 1 )
  THEN
    RETURN p_flag;
  ELSE
    RETURN NULL;
  END IF;
END;

create an index on this function

CREATE INDEX idx_maint_chg_flag
   ON a_maintenance( is_record_changed( record_changed ) );

and use this function in your query

SELECT *
  FROM a_maintenance
 WHERE is_record_changed( record_changed ) = 1

Justin

Tags: Database

Similar Questions

  • SQL not using indexes at runtime, but by using the index in "explain plan".

    Hi all

    I am facing a problem here that I don't get to think.

    I have a SQL that makes a FULL ACCESS of TABLE into two tables and its costs are very high, but it occurs only when I run it in my program (I saw it in the session trace). If I do a "explain plan" sqlplus (SQL Navigator or PLSQL Developer) it shows that he use indexes and have a low cost. I already checked the statistics from both tables, and they are up to date.

    Did someone never facing a similar problem or knows something I can do to find my problem?

    Thank you all very much.

    Hello

    As far as I KNOW, optimizer Oracle never guarantees that an Index scan in query explain plan will be necessarily used during query execution.

    ORACLE-BASE - DBMS_XPLAN: Oracle display execution Plans

    Could you please read the above, run the query, as described and check the execution using DBMS_XPLAN plan. The cursor cache DISPLAY_CURSOR and not PLAN_TABLEs.

  • Windows 7 Installer error "Setup could not use the existing system partition because it does not contain the required free space.

    Repeatedly tried to install the upgrade to windows 7 and pure install and get the error message on all partitions available "Setup could not use the existing system partition because it does not contain the required free space.  All 3 partitions on a single disk have over 90 GB and separated from the disc more than 65 GB of free space according to the properties of the disk and initial screen during installation.  Tried to reformat a partition empty all reinstall Xp sp3 without result.  What can I do?

    Remove the data cable of all drives except the drive that you want to install Windows 7 on.

    Remove all external devices.

    Delete all partitions on the disk leave all of the disc as "unallocated".

    Boot from the Windows 7 DVD and then install, when you reach the point where it asks you to select a drive, click the "Advanced" option and create a new partition (at least 50 GB) to install Windows and continue with the installation process.

    Also: http://social.technet.microsoft.com/Forums/nb-NO/w7itproinstall/thread/1b1adc74-3d94-4897-a3c1-7aabde44fe4b

    JS
    http://www.PAGESTART.com

  • During the installation of Windows 7 Ultimate, get error, "the installation program could not use the existing system partition because it does not contain the need free space."

    When installing win7 ultimate, {install} error message indicates "Setup could not use the existing system partition because it does not contain the free space required... I have 500 GB free, ram 4 GB 2.4 ghz quad... any help?"

    If you have any external storage devices such as external hard drive or thumb drive, unplug them, they might interfere with installation.

  • Can I create an index on a partitioned table bitmap?

    Can I create an index on a partitioned table bitmap?

    Yes, you can. But an index on a partitioned table bitmap must be a local index.
    Image bitmap index on non partitioned tables cannot be partitioned.

  • 11g R2 optimizer is not using indexes

    I have the table named OPT_TEST in my database 11g R2.
    There is an index on the ename column of the table above.
    11g does not use this index when I ask above table on the basis of the ename column.

    SQL > select count (*) in the opt_test;

    COUNT (*)
    ----------
    851969

    SQL > select count (*) in the opt_test where ename = 'KING '.

    COUNT (*)
    ----------
    1

    SQL > exec dbms_stats.gather_table_stats ('SCOTT', 'OPT_TEST', method_opt = > 'for all columns size skewonly');

    SQL > explain plan for select * from opt_test where ename = 'KING '.

    He explained.

    SQL > select parent_id, operation, options, object_name, id, io_cost from plan_table;

    ID PARENT_ID OPERATION OPTIONS OBJECT_NAME IO_COST
    ---------- ---------- ------------------------------ ------------------------------ ------------------------------ ----------
    0 SELECT STATEMENT 1365
    1 0 TABLE ACCESS FULL OPT_TEST 1365


    There is on one employee with the name 'KING' in the OPT_TEST table.
    I have also generated stats on the table and the index but still optimizer makes complete analysis.

    user8916506 wrote:

    SQL> select count(distinct ename) from opt_test ;
    
    COUNT(DISTINCTENAME)
    --------------------
    14
    
    SQL> select ename,count(*) from opt_test  group by ename;
    
    ENAME        COUNT(*)
    ---------- ----------
    ALLEN           65536
    JONES           65536
    FORD            65536
    CLARK           65536
    MILLER          65536
    SMITH           65536
    WARD            65536
    MARTIN          65536
    SCOTT           65536
    TURNER          65536
    ADAMS           65536
    BLAKE           65536
    KING                1
    JAMES           65536
    
    14 rows selected.
    

    The answer is b - I thought of:
    You enabled Oracle to make a sample auto size, and he stopped on a very small sample because he thought that he had obtained a stable result. But he has never seen the line after line with KING. Therefore, when you query for KING oracle saw "not in the histogram. For versions of Oracle 10.2.0.3 beyond estimation is then "half the number of lines for the least popular value', which comes to 32 768.

    Concerning
    Jonathan Lewis

  • Optimizer not use indexes even after giving the indication

    Hi all

    I wonder why the Optimixzer does not use the index in the query below
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    
    
    SQL> select column_expression
      2  from ALL_IND_EXPRESSIONS
      3  where table_name like 'GTXN_DTL_V1'
      4  and index_name = 'IDX_TXN11_V1';
    
    COLUMN_EXPRESSION
    -----------------------------------------
    TO_DATE("BOOKING_DATE",'YYYYMMDD')
    
    SQL> select num_rows from all_tables
      2  where table_name like 'GTXN_DTL_V1';
    
      NUM_ROWS
    ----------
      29020867
    
    SQL>  explain plan for select * from gtxn_dtl_v1 where to_date(booking_date,'yyyymmdd') = to_date('030109','DDMMRR');
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------------------
    Plan hash value: 3140624094
    
    ---------------------------------------------------------------------------------
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |             | 55489 |    15M|   215K  (4)| 00:43:08 |
    |*  1 |  TABLE ACCESS FULL| GTXN_DTL_V1 | 55489 |    15M|   215K  (4)| 00:43:08 |
    ---------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter(TO_DATE("BOOKING_DATE",'yyyymmdd')=TO_DATE('030109','DDMMRR
                  '))
    
    14 rows selected.
    
    --Giving Hint..
    
    SQL> explain plan for select /*+ index(gtxn_dtl_v1 IDX_TXN11_V1) */ *
      2  from gtxn_dtl_v1
      3  where to_date(booking_date,'yyyymmdd') = to_date('030109','DDMMRR')
      4  /
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------
    Plan hash value: 3140624094
    
    ---------------------------------------------------------------------------------
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |             | 55489 |    15M|   215K  (4)| 00:43:08 |
    |*  1 |  TABLE ACCESS FULL| GTXN_DTL_V1 | 55489 |    15M|   215K  (4)| 00:43:08 |
    ---------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter(TO_DATE("BOOKING_DATE",'yyyymmdd')=TO_DATE('030109','DDMMRR
                  '))
    
    14 rows selected.
    Please suggest.

    Thanks in advance,
    Jac

    Hello
    you have created the index with uppercase letters (YYYYMMDD), but you try to run the query with small letters (YYYYMMDD), while acceptable with the name of the column it is not acceptable with a part of the function of the order of the function.

    Yuri

  • View does not use index Mview underlying but mview uses indexes

    Hello

    I faced a situation where, while querying data to display based on mview does not use the index, but when we wonder of mview it uses index and produce quick results.

    Here are the details:

    
    querying from view: (completes in more than a minute even after passing hint)
    ================================
    explain plan for select /*+ index(  ITGI_CREDITOR_LEDGER_CMV ITGI_CREDITOR_LEDGER_INDX) */ * from CR_LEDGER_REP_V where vendor_id='1474911';
    
    Plan hash value: 463951623
    
    ---------------------------------------------------------------------------------------------------
    | Id  | Operation              | Name                     | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT       |                          |  9056K|  5648M| 97644   (1)| 00:00:04 |
    |*  1 |  VIEW                  | CR_LEDGER_REP_V          |  9056K|  5648M| 97644   (1)| 00:00:04 |
    |   2 |   COUNT                |                          |       |       |            |          |
    |   3 |    MAT_VIEW ACCESS FULL| ITGI_CREDITOR_LEDGER_CMV |  9056K|  2159M| 97644   (1)| 00:00:04 |
    ---------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("VENDOR_ID"=1474911)
    
    
    
    Querying from mview: (completes within a second)
    ==============================
    
    explain plan for select /*+ index(  ITGI_CREDITOR_LEDGER_CMV ITGI_CREDITOR_LEDGER_INDX) */ * from ITGI_CREDITOR_LEDGER_CMV where vendor_id='1474911';
    
    
    Plan hash value: 1726512073
    
    --------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                              | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                       |                           |    21 |  5880 |    21   (0)| 00:00:01 |
    |   1 |  MAT_VIEW ACCESS BY INDEX ROWID BATCHED| ITGI_CREDITOR_LEDGER_CMV  |    21 |  5880 |    21   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN                     | ITGI_CREDITOR_LEDGER_INDX |    22 |       |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("VENDOR_ID"=1474911)
    
    
    
    View DDL
    ========================
    
    CREATE OR REPLACE FORCE VIEW SANJAY.CR_LEDGER_REP_V
    (
       QRY,
       SR_NO,
       VENDOR_ID,
       VENDOR_TYPE,
       VENDOR_NUMBER,
       VENDOR_NAME,
       VENDOR_SITE_ID,
       VENDOR_SITE_CODE,
       GL_DATE,
       ACCOUNTING_DATE,
       PO,
       INVOICE_TYPE,
       AP_INVOICE_NO,
       INVOICE_DOC_CAT,
       AP_INVOICE_DATE,
       INVOICE_VOUCHER_NO,
       PAYMENT_VOUCHER_NO,
       CHQ_NO,
       DESCRIPTION,
       PAYMENT_DATE,
       ACC_CODE,
       PAYMENT_METHOD,
       CURR_CODE,
       DEBIT,
       CREDIT
    )
    AS
       SELECT qry,
              ROWNUM srn,
              vendor_id,
              vendor_type_lookup_code,
              vendor_no,
              vendor_name,
              vendor_site_id,
              vendor_site_code,
              gl_date,
              accounting_date,
              po_distribution_id,
              invoice_type_lookup_code,
              invoice_num,
              doc_category_code,
              invoice_date,
              inv_voucher_num,
              payment_num,
              check_number,
              description,
              pay_accounting_date,
              account_code,
              payment_method_code,
              invoice_currency_code,
              debit,
              credit
         FROM sanjay.itgi_creditor_ledger_cmv;
    
    
    
    

    The plan does not change even if I do not use advice.

    Although I said developer to use mview directly, but I did not understand this behavior.

    DB version: 12.1

    OPERATING SYSTEM: AIX 6.1

    Kind regards

    Gerard

    Note that the query on the view plan is only to apply your filter predicates on line 1, rather than against the mview in line 3. Line 2 said you that enforcement must correspond to a kind of County before it can filter which is due to the virtual rownum in your point of view.

    You need this column? In my opinion, it's meaningless. Remove the column from the view would mean that the view doesn't have to be assessed in its entirety (if not, how it will calculate rownums?) before allowing you to filter. You asked the developer to implement the work is likely to come with a different value of sr_no (if the developer is even using it?) than what he would have obtained by using the view.

    The column tries to catch a unique key for the view? Are you aware that rownum values can and will change between requests to the same table as the order lines are selected is not guaranteed. If the column is actually useful (and it is correct to calculate at this level) you then could it sense it is calculated inside the mview? This means that you can only refresh the mview completely and rownum values can (and will) only change on refresh.

  • DW broken do not use 'Scope of TH' for tables?

    When I use DW to generate a new table, he always puts in the elements "TH". This can make things difficult when dealing with CSS, because I want to apply a style to all the cells in a table, but the TH elements do not get the style because they aren't TDs. is there a way to tell DW to use plain old TD tags for all the cells instead of trying to force the sematic "table header" in there? Most often I'm not using the first row as a header, and I want not marked as such by default.

    Thank you!
    Drew

    INSERT | Table and uncheck TH options shown in the diagrams at the
    the bottom of the Panel. The setting is sticky.

    --
    Murray - ICQ 71997575
    Adobe Community Expert
    (If you * MUST * write me, don't don't LAUGH when you do!)
    ==================
    http://www.dreamweavermx-templates.com - template Triage!
    http://www.projectseven.com/go - DW FAQs, tutorials & resources
    http://www.dwfaq.com - DW FAQs, tutorials & resources
    http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
    ==================

    "Drew PCR" wrote in message
    News:eqq2cn$S4B$1@forums. Macromedia.com...
    > When I use DW to generate a new table, he always puts in the "TH".
    > elements.
    > This may make things tricky when dealing with CSS, because I want to apply
    > a
    > style to all the cells in a table, but the TH elements do not get style car
    > they
    > are not the TDs. is it possible to tell DW to use the Plains old TD tags for all
    > cells
    > instead of trying to force the sematic "table header" in there? Most
    > I am often
    > do not use the first line as a header and I don't want that to identified as such
    > by
    > by default.
    >
    > Thank you!
    > Drew
    >

  • Query is not using indexes

    Hello
    I wonder if there is a way to make my query to use an index without specifying the INDEX indicator.

    Thank you
    Laurent

    PS: I'm using 9.2.0.8
    SQL> create table lsc_t1(a number primary key, b number);
    
    Table created.
    
    SQL> create table lsc_t2(a number primary key, b number);
    
    Table created.
    
    SQL> create table lsc_t3(a number primary key, b number);
    
    Table created.
    
    SQL> insert into lsc_t1(a,b) select rownum, dbms_random.value from dual connect by level<10000;
    
    9999 rows created.
    
    SQL> insert into lsc_t2(a,b) select rownum, dbms_random.value from dual connect by level<1000;
    
    999 rows created.
    
    SQL> insert into lsc_t3(a,b) select rownum, dbms_random.value from dual connect by level<1000;
    
    999 rows created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> begin
      2    dbms_stats.gather_table_stats(user,'LSC_T1');
      3    dbms_stats.gather_table_stats(user,'LSC_T2');
      4    dbms_stats.gather_table_stats(user,'LSC_T3');
      5  end;
      6  /
    
    PL/SQL procedure successfully completed.
    
    SQL> set timi on
    SQL> select --+ INDEX(lsc_t1)
      2    * from lsc_t1
      3  where a in (select a from lsc_t2 where b<.01 union all select a from lsc_t3 where b<.01);
    
             A          B
    ---------- ----------
           140 .138460932
           161 .928661302
           281 .830010122
           440 .071851157
           443 .355640404
           516 .791276412
           598 .508219846
           600 .158621147
           643 .748363911
           747 .777346635
           836 .390349029
           869 .292453677
           874 .914353702
           881 .930301092
    
    14 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> select
      2    * from lsc_t1
      3  where a in (select a from lsc_t2 where b<.01 union all select a from lsc_t3 where b<.01);
    
             A          B
    ---------- ----------
           140 .138460932
           161 .928661302
           281 .830010122
           440 .071851157
           443 .355640404
           516 .791276412
           598 .508219846
           600 .158621147
           643 .748363911
           747 .777346635
           836 .390349029
           869 .292453677
           874 .914353702
           881 .930301092
    
    14 rows selected.
    
    Elapsed: 00:00:00.26
    SQL> set timi off autot trace exp
    SQL> select --+ INDEX(lsc_t1)
      2    * from lsc_t1
      3  where a in (select a from lsc_t2 where b<.01 union all select a from lsc_t3 where b<.01);
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=19 Card=17 Bytes=476)
       1    0   NESTED LOOPS (Cost=19 Card=17 Bytes=476)
       2    1     VIEW OF 'VW_NSO_1' (Cost=2 Card=17 Bytes=68)
       3    2       SORT (UNIQUE)
       4    3         UNION-ALL
       5    4           TABLE ACCESS (FULL) OF 'LSC_T2' (Cost=2 Card=9 Bytes=216)
       6    4           TABLE ACCESS (FULL) OF 'LSC_T3' (Cost=2 Card=8 Bytes=192)
       7    1     TABLE ACCESS (BY INDEX ROWID) OF 'LSC_T1' (Cost=1 Card=1 Bytes=24)
       8    7       INDEX (UNIQUE SCAN) OF 'SYS_C001186489' (UNIQUE)
    
    
    
    SQL> select
      2    * from lsc_t1
      3  where a in (select a from lsc_t2 where b<.01 union all select a from lsc_t3 where b<.01);
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=17 Bytes=476)
       1    0   NESTED LOOPS (Cost=6 Card=17 Bytes=476)
       2    1     TABLE ACCESS (FULL) OF 'LSC_T1' (Cost=6 Card=9999 Bytes=239976)
       3    1     VIEW OF 'VW_NSO_1'
       4    3       SORT (UNIQUE)
       5    4         UNION-ALL (PARTITION)
       6    5           TABLE ACCESS (BY INDEX ROWID) OF 'LSC_T2' (Cost=2 Card=1 Bytes=24)
       7    6             INDEX (UNIQUE SCAN) OF 'SYS_C001186490' (UNIQUE) (Cost=1 Card=1)
       8    5           TABLE ACCESS (BY INDEX ROWID) OF 'LSC_T3' (Cost=2 Card=1 Bytes=24)
       9    8             INDEX (UNIQUE SCAN) OF 'SYS_C001186491' (UNIQUE) (Cost=1 Card=1)

    Laurent,

    If check you my post carefully, you'll notice that the rewrite "is" using the filter outside the "union all" condition generates a plan that is - though not identical due to the operation "UNIQUE SORT" being outside instead of inside the definition of the view - point of view 'execution', 'equality' from my point of view. Please let me know if you think that this is not the case.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

    Published by: Randolf Geist Sep 22, 2008 10:09

    Solution of Tubby is not due to the execution of the sort after the LOOP IMBRIQUEE

  • 1.5.4 - SQL-spreadsheet SQL-Developer does not use the owner of the Table

    In older versions of the sql developer, you can remove a table in the spreadsheet and was built a select query. With the new version 1.5.4 - owner of the table is ' % s ' and you must inform the owner of the table or the query does not work with tables of other users.

    Is this a bug or is there the possibility to change the settings to delete tables in the SQL-worksheet with the owners of the table.

    You're DND from the node of the Table under the node of the other user? If so, I'm able to reproduce the problem you're talking about. Otherwise I still not got you problem clearly.

  • Index is not used, although suspicion.

    DBVersion: 10.2.0.3
     CREATE TABLE "ESW"."DURCHLAUFZEIT_SONDER_AG" 
       (     "AG" NUMBER(3,0) DEFAULT 0 NOT NULL ENABLE, 
         "TAGE" NUMBER(5,0) DEFAULT 0 NOT NULL ENABLE, 
         "ABTEILUNG" VARCHAR2(20 BYTE), 
    
    Content of this table
    AG    TAGE  ABTEILUNG
    910     1     EAV
    133     1     TG
    743     2     TM
    719     2     TM
    706     2     TM
    979     10     TM
    When I use a select statement like that no index on tabel 'walze w2' is used:
    select /*+ index(apl(arbeitsgang_nr))*/
           /*+ index(w2 WALZE_IND1)*/
            SUM (dsa.tage) tage,
             w2.walzen_nr walzen_nr,
            w2.walzen_ng walzen_ng
          from durchlaufzeit_sonder_ag dsa,
               auftrag_arbeitsplan apl,
               walze w2
          where apl.arbeitsgang_nr in
              ( select dsa1.ag ag
                from durchlaufzeit_sonder_ag dsa1
                where dsa1.abteilung = 'TM' )*and apl.auftr_nr = w2.auftr_nr
    and apl.auftr_jj = w2.auftr_jj
    and apl.auftr_pos = w2.auftr_pos
    and apl.auftr_los = w2.auftr_los
    and dsa.abteilung = 'TM' 
    and dsa.ag = apl.arbeitsgang_nr
    GROUP BY w2.walzen_nr,
         w2.walzen_ng;
    
    --------------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name                           | Rows  | Bytes | Cost  |
    --------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |                                |    21 |  1155 |  4927 |
    |   1 |  SORT GROUP BY                  |                                |    21 |  1155 |  4927 |
    |*  2 |   HASH JOIN                     |                                |    21 |  1155 |  4922 |
    |   3 |    NESTED LOOPS                 |                                |   333 | 11655 |  4682 |
    |   4 |     NESTED LOOPS                |                                | 16215 |   427K|  4682 |
    |   5 |      TABLE ACCESS BY INDEX ROWID| DURCHLAUFZEIT_SONDER_AG        |     4 |    40 |     2 |
    |*  6 |       INDEX RANGE SCAN          | DURCHLAUFZEIT_SONDER_AG_INDEX1 |     4 |       |     1 |
    |   7 |      TABLE ACCESS BY INDEX ROWID| AUFTRAG_ARBEITSPLAN            |  4054 | 68918 |  1170 |
    |*  8 |       INDEX RANGE SCAN          | AUFTRAG_ARBEITSPLAN_IND3       |  4054 |       |     7 |
    |*  9 |     INDEX RANGE SCAN            | DURCHLAUFZEIT_SONDER_AG_INDEX2 |     1 |     8 |       |
    |  10 |    *TABLE ACCESS FULL*            | WALZE                          | 75432 |  1473K|   239 |
    --------------------------------------------------------------------------------------------------
    When I run the same sql to the delivery of the selection from tabel 'durchlaufzeit_sonder_ag' by my own index is used:
    select /*+ index(apl(arbeitsgang_nr))*/
           /*+ index(w2 WALZE_IND1)*/
            SUM (dsa.tage) tage,
             w2.walzen_nr walzen_nr,
            w2.walzen_ng walzen_ng
          from durchlaufzeit_sonder_ag dsa,
               auftrag_arbeitsplan apl,
               walze w2
          where apl.arbeitsgang_nr in
                          ( 743, 719, 706, 979 )
    and apl.auftr_nr = w2.auftr_nr
    and apl.auftr_jj = w2.auftr_jj
    and apl.auftr_pos = w2.auftr_pos
    and apl.auftr_los = w2.auftr_los
    and dsa.abteilung = 'TM' 
    and dsa.ag = apl.arbeitsgang_nr
    GROUP BY w2.walzen_nr,
    w2.walzen_ng;
    
    ---------------------------------------------------------------------------------------------------
    | Id  | Operation                        | Name                           | Rows  | Bytes | Cost  |
    ---------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                 |                                |     2 |    94 |  1161 |
    |   1 |  SORT GROUP BY                   |                                |     2 |    94 |  1161 |
    |   2 |   TABLE ACCESS BY INDEX ROWID    | WALZE                          |     1 |    20 |     2 |
    |   3 |    NESTED LOOPS                  |                                |     2 |    94 |  1156 |
    |*  4 |     HASH JOIN                    |                                |    31 |   837 |  1094 |
    |   5 |      INLIST ITERATOR             |                                |       |       |       |
    |   6 |       TABLE ACCESS BY INDEX ROWID| DURCHLAUFZEIT_SONDER_AG        |     3 |    30 |     2 |
    |*  7 |        INDEX RANGE SCAN          | DURCHLAUFZEIT_SONDER_AG_INDEX2 |     3 |       |     1 |
    |   8 |      INLIST ITERATOR             |                                |       |       |       |
    |   9 |       TABLE ACCESS BY INDEX ROWID| AUFTRAG_ARBEITSPLAN            |  2276 | 38692 |  1091 |
    |* 10 |        INDEX RANGE SCAN          | AUFTRAG_ARBEITSPLAN_IND3       |  2276 |       |     8 |
    |* 11 |     INDEX RANGE SCAN             | WALZE_IND1                     |     1 |       |     1 |
    ---------------------------------------------------------------------------------------------------
    I don't understand this. Why oracle do not use index (provided in the indicator) when I select the values in the durchlaufzeit_sonder_ag table, but when they provide my own values, it uses the index?

    As far as I know only the first comment of suspicion in a given query block is considered.

    So it would be valid (unless hint_one is specified correctly)...

    SELECT /*+ hint_one hint_two */
           column_name
    FROM   table_name;
    
    SELECT /*+
           hint_one
           hint_two
           */
           column_name
    FROM   table_name;
    
    SELECT /*+ hint_one
           hint_two */
           column_name
    FROM   table_name;
    
    SELECT --+ hint_one hint_two
           column_name
    FROM   table_name;
    

    But this should not (regardless of if hint_one is specified correctly)...

    SELECT /*+ hint_one */
           /*+ hint_two */
           column_name
    FROM   table_name;
    

    Also I do not believe your INDEX index specification is correct, a single set of brackets should be used and the alias name and index table must be separated by a space or a comma.

    So it would be nice...

    SELECT /*+ INDEX (table_alias index_name) */
           column_name
    FROM   table_name;
    
    SELECT /*+ INDEX (table_alias, index_name) */
           column_name
    FROM   table_name;
    

    But it would not...

    SELECT /*+ INDEX (table_alias (index_name)) */
           column_name
    FROM   table_name;
    

    Also, you should be aware that an INDEX indicator is only considered provided that supports a given join order.

  • [SQL] Tuning why he can't use indexes?

    Here's a SQL that cannot use indexes

    SELECT T.FID FID,

    t.cfsignState SIGNSTATE,

    T.FNUMBER WBNUMBER,

    T1. CFCUSTOMERTRANSNUMBER CUNUMBER,

    T2. CFCOMPANYNAME CUSTOMERNAME,

    T.CFATTACHMENTFILE ATTFILE,

    T.CFATTACHMENT ATT

    OF CT_OPE_SIGNBILL T

    LEFT OUTER JOIN CT_OPE_WAYBILL T1

    ON T1. FID = T.CFWAYBILLID

    LEFT OUTER JOIN T2 CT_MAR_CUSTOMER

    ON T2. FID = T1. CFCUSTOMERID

    WHERE ((T.FNUMBER ('1410582816' N)) OR (T1.) CFCUSTOMERTRANSNUMBER (N '1410582816')));

    Elapsed time: 00:00:12.15

    Execution plan

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

    Hash value of plan: 2925502694

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

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

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

    |   0 | SELECT STATEMENT |                 |     2.   420.       | 48996 (3) | 00:01:16 |       |       |

    |   1.  NESTED EXTERNAL LOOPS |                 |     2.   420.       | 48996 (3) | 00:01:16 |       |       |

    |*  2 |   FILTER |                 |       |       |       |            |          |       |       |

    |*  3 |    EXTERNAL RIGHT HASH JOIN |                 |     2.   310.    67 M | 48995 (3) | 00:01:16 |       |       |

    |   4.     RANGE OF PARTITION ALL THE |                 |  1241K |    53 M |       | 36422 (3) | 00:00:57 |     1.    63.

    |   5.      TABLE ACCESS FULL | CT_OPE_WAYBILL |  1241K |    53 M |       | 36422 (3) | 00:00:57 |     1.    63.

    |   6.     TABLE ACCESS FULL | CT_OPE_SIGNBILL |   907K |    95 M |       |  8217 (5) | 00:00:13 |       |       |

    |   7.   TABLE ACCESS BY INDEX ROWID | CT_MAR_CUSTOMER |     1.    55.       |     1 (0) | 00:00:01 |       |       |

    |*  8 |    INDEX UNIQUE SCAN | PK_MAR_CUSTOMER |     1.       |       |     1 (0) | 00:00:01 |       |       |

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

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

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

    2 - filter("T".") FNUMBER ' = U ' 1410582816 "OR 'T1'. '. CFCUSTOMERTRANSNUMBER '= U '1410582816')

    3 - access("T1".") IDF"(+) ="T ". ("' CFWAYBILLID")

    8 - access("T2".") IDF"(+) ="T1 ". ("' CFCUSTOMERID")

    Statistics

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

    1 recursive calls

    19 db block Gets

    234698 compatible Gets

    191546 physical reads

    0 redo size

    1035 bytes sent via SQL * Net to client

    524 bytes received via SQL * Net from client

    2 SQL * Net back and forth to and from the client

    0 sorts (memory)

    0 sorts (disk)

    1 rows processed

    but, if I rewrite it as below, it can use indexes

    SELECT T.FID FID,

    t.cfsignState SIGNSTATE,

    T.FNUMBER WBNUMBER,

    T1. CFCUSTOMERTRANSNUMBER CUNUMBER,

    T2. CFCOMPANYNAME CUSTOMERNAME,

    T.CFATTACHMENTFILE ATTFILE,

    T.CFATTACHMENT ATT

    OF CT_OPE_SIGNBILL T

    LEFT OUTER JOIN CT_OPE_WAYBILL T1

    ON T1. FID = T.CFWAYBILLID

    LEFT OUTER JOIN T2 CT_MAR_CUSTOMER

    ON T2. FID = T1. CFCUSTOMERID

    WHERE ((T.FNUMBER (N '1410582816')))

    Union

    SELECT T.FID FID,

    t.cfsignState SIGNSTATE,

    T.FNUMBER WBNUMBER,

    T1. CFCUSTOMERTRANSNUMBER CUNUMBER,

    T2. CFCOMPANYNAME CUSTOMERNAME,

    T.CFATTACHMENTFILE ATTFILE,

    T.CFATTACHMENT ATT

    OF CT_OPE_SIGNBILL T

    LEFT OUTER JOIN CT_OPE_WAYBILL T1

    ON T1. FID = T.CFWAYBILLID

    LEFT OUTER JOIN T2 CT_MAR_CUSTOMER

    ON T2. FID = T1. CFCUSTOMERID

    WHERE ((T1. CFCUSTOMERTRANSNUMBER (N '1410582816')));

    Elapsed time: 00:00:00.02

    Execution plan

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

    Hash value of plan: 2215743926

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

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

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

    |   0 | SELECT STATEMENT |                          |     2.   420.    11 (64) | 00:00:01 |       |       |

    |   1.  UNIQUE FATE |                          |     2.   420.    11 (64) | 00:00:01 |       |       |

    |   2.   UNION-ALL |                          |       |       |            |          |       |       |

    |   3.    NESTED EXTERNAL LOOPS |                          |     1.   210 |     4 (0) | 00:00:01 |       |       |

    |   4.     NESTED EXTERNAL LOOPS |                          |     1.   155.     3 (0) | 00:00:01 |       |       |

    |   5.      TABLE ACCESS BY INDEX ROWID | CT_OPE_SIGNBILL |     1.   110.     2 (0) | 00:00:01 |       |       |

    |*  6 |       INDEX RANGE SCAN | IDX_CT_OPE_SIGNBILL_IT01 |     1.       |     1 (0) | 00:00:01 |       |       |

    |   7.      TABLE ACCESS BY INDEX ROWID | CT_OPE_WAYBILL |  1241K |    53 M |     1 (0) | 00:00:01 | ROWID | ROWID |

    |*  8 |       INDEX UNIQUE SCAN | CPK_OPE_WAYBILLBP7 |     1.       |     1 (0) | 00:00:01 |       |       |

    |   9.     TABLE ACCESS BY INDEX ROWID | CT_MAR_CUSTOMER | 25598 |  1374K |     1 (0) | 00:00:01 |       |       |

    | * 10 |      INDEX UNIQUE SCAN | PK_MAR_CUSTOMER |     1.       |     1 (0) | 00:00:01 |       |       |

    |  11.    NESTED LOOPS |                          |     1.   210 |     5 (0) | 00:00:01 |       |       |

    |  12.     NESTED EXTERNAL LOOPS |                          |     1.   100.     4 (0) | 00:00:01 |       |       |

    |  13.      TABLE ACCESS BY INDEX ROWID | CT_OPE_WAYBILL |     1.    45.     3 (0) | 00:00:01 | ROWID | ROWID |

    | * 14 |       INDEX RANGE SCAN | IDX$ $_47CB0003 |     1.       |     2 (0) | 00:00:01 |       |       |

    |  15.      TABLE ACCESS BY INDEX ROWID | CT_MAR_CUSTOMER |     1.    55.     1 (0) | 00:00:01 |       |       |

    | * 16.       INDEX UNIQUE SCAN | PK_MAR_CUSTOMER |     1.       |     1 (0) | 00:00:01 |       |       |

    |  17.     TABLE ACCESS BY INDEX ROWID | CT_OPE_SIGNBILL |     1.   110.     2 (0) | 00:00:01 |       |       |

    | * 18.      INDEX RANGE SCAN | IDX$ $_47C30001 |     1.       |     1 (0) | 00:00:01 |       |       |

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

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

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

    6 - access("T".") FNUMBER "= U '1410582816')

    8 - access("T1".") IDF"(+) ="T ". ("' CFWAYBILLID")

    10 - access("T2".") IDF"(+) ="T1 ". ("' CFCUSTOMERID")

    14 - access("T1".") CFCUSTOMERTRANSNUMBER '= U '1410582816')

    16 - access("T2".") IDF"(+) ="T1 ". ("' CFCUSTOMERID")

    18 - access("T1".") IDF '=' T '. ("' CFWAYBILLID")

    Statistics

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

    1 recursive calls

    0 db block Gets

    Gets 11 coherent

    0 physical reads

    0 redo size

    1035 bytes sent via SQL * Net to client

    524 bytes received via SQL * Net from client

    2 SQL * Net back and forth to and from the client

    1 sorts (memory)

    0 sorts (disk)

    1 rows processed

    SQL >

    My Question is why the first statement cannot use indexes? What is its mechanism?

    as Maria Colgan explains in his commentary on https://blogs.oracle.com/optimizer/entry/or_expansion_transformation: "since OR expansion is a transformation focused on costs, it cannot always take place." It cannot take place, then it can be forced by using the indicator, USE_CONCAT. "Fundamentally OR expansion is

    a transformation that can be used to optimize the disjunctive queries (queries that contain clauses of GOLD). The basic idea of in the expansion of the GOLD is to transform a query containing the disjunctions in the form of a query UNION ALL of two or more branches. This is done by dividing the disjunction in components and by associating each component with a branch of a query UNION all.

    So, you can use the USE_CONCAT flag to check if OR expansion is an option at all for the optimizer in your example. The strategy itself is quite old and mentioned by Tom Kyte in https://asktom.oracle.com/pls/apex/f?p=100:11:0:P11_QUESTION_ID:921229345078.

  • CTXCAT index on partitioned tables

    Hi all

    I use an oracle 11.2 database and try to use the index for a sample application oracle CTXCAT.

    I saw that oracle reference documentation "the CTXCAT index can't stand table and index partitioning, not...» "in http://docs.oracle.com/cd/B28359_01/text.111/b28303/ind.htm#BEIIEAFD

    But I was able to create a CTXCAT index on a partitioned table query to use it successfully.

    So can someone tell me exactly it meaning in the documentation of oracle developer "CTXCAT index does not support index and table partitioning?

    Thanks in advance,

    Mor.

    This simply means that you cannot create a LOCAL partitioned index on a table partitioned using the CTXCAT indextype. There is not probably the creation of a global index (ie. covering all partitions) on a partitioned table.

    The wording could be clearer.

  • Unusable index Partitioned table

    Oracle Version: 11.2.0.2
    OS: Linux RHEL 5

    I'm having a problem with the index on a partitioned table interval. This is the scenario:

    There are 3 indices (A, B, C) on a table. A is created on two columns (1,2), B is on the column (2), C is the column (3). Table is partitioned on column 2 apart. A and B are partitioned indexes. When I drop a partition without a clause to update index, Index C will unusable. After seeing this, I gave up the C rating and create it as a local partitioned index, then all indexes are in condition of use after the drop partition statement. Is - this mandatory on a range partitioned table all indexes on the table must be locally partitioned inorder to have indexes in usable state after the drop statement of partition (without the update index clause)? Also there will be a negative impact for all indexes on the table like locally partitioned indexes?

    >
    Is - this mandatory on a range partitioned table all indexes on the table must be locally partitioned inorder to have indexes in usable state after the drop statement of partition (without the update index clause)?
    >
    Yes - it should be obvious by looking at a simple example.

    You have an OVERALL index and drop a partition but say Oracle are NOT updating the overall index.

    How this index may be usable for anything? It is not accurate. There was GARBAGE everywhere that gets in the way of Oracle find the entries of the "good". There are the index keys in the branch blocks that belong to the partition that has been deleted. Oracle cannot use these keys to determine how the blocks of branch, he needs to find.
    >
    Also there will be a negative impact for all indexes on the table like locally partitioned indexes?
    >
    Who knows? There are maybe or maybe not.

    As with many things Oracle "it depends."

    It depends on what types of queries that you ran.

    It depends on the filter predicates used for query.

    It depends on if the maintenance simple score (add/drop/split) are important to you.

    For the maintenance of the partition only all index LOCAL is the best.

    For full table scan, an index is not intended to be used.

    For a query that needs all THE records for a COMPANY_ID given in a table partitioned by DATE an OVERALL index could be better. Oracle also use 100 index LOCAL (if there are 100 partitions) to get the same data.

    It depends on.

Maybe you are looking for

  • Safari crashes

    The web browsers, safari and chrome break constantly for past week 3. What should do? Is this a bug?

  • Upgrade hardware on Qosmio X 770 - 127

    Hello. I had 2 years a qosmio x 770 127, but today, in my view, it lacks in graphics performance (6.2 for windows 7) Maybe a possibility at this level with a new material? (I don't think but maybe!) Or is it possible that a commercial toshiba make me

  • Re: Satellite Pro P100 (PSPAEE) turn on automatically

    Hello My PSPAEE P100 is under Vista 32-bit, that it came with and it has since turned on new itself on the time standby or hibernation. It's as if it has a sensor of movement inside and as soon as I move or get to work or to a customer his switched i

  • Max RAM HP530

    HelloMy question is about the maximum RAM I can add to my HP530 laptop, I read a lot of forum that the motherboard only supported 2 GB Ram (Ddr2 1 GB per slot), but yesterday I tried with 4 GB of RAM (2x2gb) and the spectacle of the Bios and Windows

  • Expson printer LIGHT incandescent guard

    Original title: help please I reinstalled my xp-215 Epson printer again and changed the ink cartridges, but the light on the right side of the printer stops appear you have any idea how I can stop this light showing it please it is stop using the pri