Index Usage and 'OR' Clause

I am executing following SQL but index is not getting used.
SELECT instement_id
FROM instrument
WHERE instrument_id = 100
OR 1=1
I have an index on instrument.instrument_id but it is not getting used the oprimizer is going for full table scam...
when i remove 1=1 then index on instrument_id is used...
but i am not able to understand the logic that if i add 1=1 in 'OR' Clause then why index is not getting used.
This is urgent..let me know asap...
Thanks
Rohit

How selective is INSTRUMENT_ID? Is that a primary key? Or are there many rows in the INSTRUMENT table with an INSTRUMENT_ID of 1?
Are the statistics on your table and your index up to date? How, precisely, were statistics gathered?
What version of Oracle are you using? If you are using something earlier than 11.1, it's entirely possible that you have a bind variable peeking problem.
Realistically, you would want Oracle to use two different query plans for this statement depending on the value of the bind variable. If you pass in a NULL, you'd want Oracle to do a table scan. If you pass in a value, you'd want Oracle to do an index scan. Prior to 11.1, when this statement is first parsed, Oracle looks at the bind variable you passed in and picks the best plan for that bind variable value. When you subsequently execute this statement with other bind variable values, that first query plan is used. Thus, if the first time this code was executed you passed in a NULL, it would have made sense for Oracle to choose the table scan and all subsequent executions (until the query was aged out of the shared pool) would continue to use that query plan.
Oracle 11.1 introduced the ability to have multiple query plans for the same query depending on the bind variable values that were passed in which may well alleviate the problem you're seeing.
Justin

Similar Messages

  • Index usage and nested views

    We've got some performance problems when using a complex view that queries against a couple nested views.
    We need to use views because we have two outer joins against the same table.
    Here's a simplified version:
    create or replace view_b as
    select a1, b1, c1, d1
    from table_c, table_d, view_a
    where table_c.c1 = view_a.a1(+)
    and table_c.c2= table_d.d1
    create or replace view_a as
    select a1
    from table_a, table_b
    where table_a.a1 = table_b.b1(+)
    A query that may present problems with large amounts of data is:
    select a1, b1
    from view_b
    where a1 = 1234;
    Do indexes of nested views get utilized? Any suggestions?
    Thanks

    How selective is INSTRUMENT_ID? Is that a primary key? Or are there many rows in the INSTRUMENT table with an INSTRUMENT_ID of 1?
    Are the statistics on your table and your index up to date? How, precisely, were statistics gathered?
    What version of Oracle are you using? If you are using something earlier than 11.1, it's entirely possible that you have a bind variable peeking problem.
    Realistically, you would want Oracle to use two different query plans for this statement depending on the value of the bind variable. If you pass in a NULL, you'd want Oracle to do a table scan. If you pass in a value, you'd want Oracle to do an index scan. Prior to 11.1, when this statement is first parsed, Oracle looks at the bind variable you passed in and picks the best plan for that bind variable value. When you subsequently execute this statement with other bind variable values, that first query plan is used. Thus, if the first time this code was executed you passed in a NULL, it would have made sense for Oracle to choose the table scan and all subsequent executions (until the query was aged out of the shared pool) would continue to use that query plan.
    Oracle 11.1 introduced the ability to have multiple query plans for the same query depending on the bind variable values that were passed in which may well alleviate the problem you're seeing.
    Justin

  • Index usage in depending on where clause changes.

    Hello Friends,
    I need your help for one issue.
    I have one query , which is using two table Say T1 and T2, where C1 is common column using which both are joined.
    C1 is primary key in T1, but no index available in T2 for C1. T1C2 is the column which we want to select.
    (Note that Either of table can be a Master table)
    Now see the query:
    Select T1C2
    From T1, T2
    where T2.C1 = T1.C1
    Here where clause may have other conditions and From clause may have others tables as per requirements.
    I want to know that, if, I change the query like following to let my query use the available index of T1.C1.
    Select T1C2
    from T1, T2
    where T1.C1 = T2.C1
    Then, Will the query use the available index of T1. and Will i get better performance. Even a little improvement in performance may help me a lot as this kind of query is being used within a where loop (so it is going to be executed multiple times).
    Please advise on this..
    Regards,
    Dipali..

    Hi,
    18:43:17 rel15_real_p>create table t1(c1 number primary key, c2 number);
    Table created.
    18:43:26 rel15_real_p>create table t2(c1 number, c2 number);
    18:45:08 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t1(c1,c2) values (i,i+100);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    PL/SQL procedure successfully completed.
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t2(c1,c2) values (i,i+200);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    18:45:23 rel15_real_p>select count(*) from t1;
      COUNT(*)
           100
    18:45:30 rel15_real_p>select count(*) from t2;
      COUNT(*)
           100
    18:45:49 rel15_real_p>select index_name,index_type from user_indexes where table
    _name='T1';
    INDEX_NAME                     INDEX_TYPE
    SYS_C0013059                   NORMAL
    18:48:21 rel15_real_p>set autotrace on
    18:52:25 rel15_real_p>Select T1.C2
    18:52:29   2  From T1, T2
    18:52:29   3  where T2.C1 = T1.C1
    18:52:29   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=100 Bytes=
              900)
       1    0   HASH JOIN (Cost=7 Card=100 Bytes=3900)
       2    1     TABLE ACCESS (FULL) OF 'T1' (TABLE) (Cost=3 Card=100 By
              es=2600)
       3    1     TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 By
              es=1300)
    Statistics
              0  recursive calls
              0  db block gets
             21  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            100  rows processed
    18:52:31 rel15_real_p>analyze table t1 compute statistics;
    Table analyzed.
    18:55:35 rel15_real_p>analyze table t2 compute statistics;
    18:55:38 rel15_real_p>set autotrace on
    18:55:42 rel15_real_p>Select T1.C2
    18:55:43   2  From T1, T2
    18:55:45   3  where T2.C1 = T1.C1
    18:55:46   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    Statistics
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed
    18:56:56 rel15_real_p>Select T1.C2
    18:56:56   2  From T1, T2
    18:56:56   3  where T1.C1 = T2.C1
    18:56:58   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    Statistics
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed- Pavan Kumar N

  • Case insensitive search and "IN" Clause in Open SQL

    Hi,
    I have some doubts regarding Open SQL:
    - Is there any support for Case Insensitive Search in Open SQL, is it availabe by default?
    - Is there any restriction on number of elements in "IN" Clause, in Open SQL, is there any default number?
    I have checked the [Open SQL Grammer |http://help.sap.com/saphelp_nwce711/helpdata/en/9b/f46cabaa874bc9a82234e8cf1d0696/frameset.htm]also, but nothing found there.
    Thanks,
    Piyush
    P.S I didn't find any other appropriate place to post this thread, let me know the correct categorization of Open SQL in case its wrong.

    > I have some doubts regarding Open SQL:
    I believe that you've questions and not doubts...
    > - Is there any support for Case Insensitive Search in Open SQL, is it availabe by default?
    Nope, there is nothing like that. By default all supported database use a bytewise equal operator - case insensitivness needs to be programmed by hand.
    E.G. using UPPER(x)/LOWER(x) functions.
    Be aware that this disables the possibilities of index usage.
    > - Is there any restriction on number of elements in "IN" Clause, in Open SQL, is there any default number?
    Yes, there is a restriction and it differes between the different DBMS.
    Until recently you could have 2000 variables per statement with MaxDB.
    The current versions of DBSL and MaxDB Kernel now support up to 10000 variables per statement.
    Anyhow, in most cases, such a long in list can and should be avoided by using the FOR ALL ENTRIES construct. With this, the DBSL automatically splits the long IN list into smaller chunks and executes the statements several times.
    This is invisible to the ABAP report - it just gets the result set as usual.
    > P.S I didn't find any other appropriate place to post this thread, let me know the correct categorization of Open SQL in case its wrong.
    I guess in anyone of the DB forums is Ok.
    regards,
    Lars

  • Different b/w index rebuild and index rebuild online

    hi..guys could u plz tel me difference between index rebuild and index rebuild online

    There is no difference in both the commands. Both will rebuild the index structure from the scratch.But in the first case with only Rebuild, as long as the index, its temporary segment is not prepared and merged together, index is not available for the other users for use. The Online clause makes the index available for others even while being rebuild.
    Rebuilding index online has the same concept of creating them online to some extent,
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96521/indexes.htm#3062
    HTH
    Aman....

  • UNUSED EXISTING INDEXES / Index usage

    We are using CRM 2007, Netweaver 7.0 with DB2 UDB v9.1 fixpack4 on AIX.
    Is there a way to find out  UNUSED EXISTING INDEXES for tables ? We have close 12 indexes on the crmd_order_index table and want to find out if some of them can safely deleted. Is there any way to monitor index usage in SAP ? Is there any toold to aid this ?
    Pls advise.
    thank you
    regards
    Laxmi

    Laxmi,
    I am not aware of any such tools with DB2 9.1.  However, "last_used" columns are being added to various catalog tables in DB2 9.7.  Below is an excerpt from a slide presented in the  TLU2008A "DB2 LUW V9.7 Cobra u2013 Storage is Charmed" session.
    The last reference time of an object will now be maintained in the LASTUSED column of
    the corresponding catalog table for the object
    u2013 SYSCAT.INDEXES.LASTUSED (prior to V9.7 db2pd u2013tcbstats indexes)
    u2013 SYSCAT.TABLES.LASTUSED
    u2013 SYSCAT.DATAPARTITIONS.LASTUSED
    u2013 SYSCAT.PACKAGE.LASTUSED
    The LASTUSED column is of type DATE (default value is 1/1/0001)
    Use Cases:
    u2013 Detach table partitions that are no longer actively used (esp. when not partitioned by time)
    u2013 Determine inactive or infrequently used indexes
    u2013 Easily identify tables which are no longer in use
    u2013 Get rid of unused packages
    The presenter said the code will begin populating these columns in an upcoming fixpack.
    Regards,
    Rick

  • Index usage depends on columns selected

    Hi, somehow cannot understand why index is not used, please help.
    in Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
    1.     Included only indexed column and got a perfect plan
    explain plan for2 select s.x_cnt
    3 from reported_summary s
    4 where s.x_cnt>0;
    PLAN_TABLE_OUTPUT
    Plan hash value: 2674489506
    | Id | Operation | Name | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 306 (8)|
    |* 1 | INDEX FAST FULL SCAN| S_NUI01 | 306 (8)|
    Predicate Information (identified by operation id):
    1 - filter("s"."x_CNT">0)
    2.     Included some other column and got TABLE ACCESS FULL
    explain plan for2 select s.x_cnt,s.ru_id
    3 from reported_summary s
    4 where s.x_cnt>0;
    PLAN_TABLE_OUTPUT
    Plan hash value: 2142873335
    | Id | Operation | Name | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 2421 (3)|
    |* 1 | TABLE ACCESS FULL| REPORTED_SUMMARY | 2421 (3)|
    Predicate Information (identified by operation id):
    1 - filter("s"."x_CNT">0)
    3.     Included all other columns and got TABLE ACCESS FULL as well
    explain plan for2 select s.x_cnt,s.*
    3 from reported_summary s
    4 where s.x_cnt>0;
    PLAN_TABLE_OUTPUT
    Plan hash value: 2142873335
    | Id | Operation | Name | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 2421 (3)|
    |* 1 | TABLE ACCESS FULL| REPORTED_SUMMARY | 2421 (3)|
    Predicate Information (identified by operation id):
    1 - filter("s"."x_CNT">0)
    Thanks a lot

    Thanks all, just to clarify
    "select s.x_cnt from reported_summary s..." is using index;
    "select 'Y' y from reported_summary s..." is using index;
    "select <any ohter column> from reported_summary s..." is causing TABLE ACCESS FULL;
    no differences in where clause, no order by at all
    the index script is
    CREATE INDEX S_NUI01 ON REPORTED_SUMMARY (OFFSET_CNT) TABLESPACE X_INDEXES;
    jgarry, thanks for the answer, the only problem that I have clone of the database (32 bit) with same CBO parameters
    where it does not behave this way:
    explain plan for2 select s.offset_cnt
    3 from reported_summary s
    4 where s.offset_cnt>0;
    PLAN_TABLE_OUTPUT
    Plan hash value: 2359470296
    | Id | Operation | Name | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 9 (0)|
    |* 1 | INDEX RANGE SCAN| S_NUI01 | 9 (0)|
    Predicate Information (identified by operation id):
    1 - access("s"."OFFSET_CNT">0)
    explain plan for2 select s.offset_cnt,s.ru_id
    3 from reported_summary s
    4 where s.offset_cnt>0;
    PLAN_TABLE_OUTPUT
    Plan hash value: 3732627180
    | Id | Operation | Name | Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 67 (0)|
    | 1 | TABLE ACCESS BY INDEX ROWID| REPORTED_SUMMARY | 67 (0)|
    |* 2 | INDEX RANGE SCAN | S_NUI01 | 9 (0)|
    Predicate Information (identified by operation id):
    2 - access("s"."OFFSET_CNT">0)
    Thanks again.

  • 'IS NOT NULL' & Index Usage

    Hi,
    there are many queries my one of my packages, which has the SQL as follows:
    Update table XYZ
    Set Column A = NULL
    Where Colum B IS NOT NULL;
    Column B has NUMBER datatype.
    Due to 'IS NOT NULL' the index (existing for Column B' is not being used in the above query, leading to Full table scan. Is there any ways of forcing teh index to be picked/used by the query?
    Thanks,
    Rosalin

    thansk again for response. Checked the % of the data
    fetched by this query and it ranges from 20% to 50
    %(varies due to teh fact the table data content could
    have different set of data depending on the days
    transactions done). So for sure index usage would
    help.
    Additionally this sql(used in multiple places) come
    up in the v$longsops output.
    so definitely needs tuning.
    Any suggestions?That's not really true though if you understand the mechanisms employed for a full table scan vs an index scan / table lookup (by rowid since the table must also be visited).
    Here's something good for you to read
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4433887271030
    A full tablescan reads the table using large sequential reads -- many blocks at a time.
    Sequential reads are the fastest type of IO you can do on a disk in general.
    An index read will do single block, random IO's. These are generally the slowest you can
    do.
    I would suggest to you that if you have statistics on the table/indexes that are representative of the data, the Optimizer will be smarter than you (most cases, not all).
    Message was edited by:
    Tubby

  • SQL INDEX USAGE

    hi,
    I have a procedure which took 15-20 minutes in the past to execute.Suddently it is taking 2 hours.When i examined i came to know that the sql statement is not using one of the index.I dropped the index and created it.The explain plan is generated but still the index is not being used.I forced the index usage by using the index hint
    SELECT /*+ INDEX(test_his test_hist_idx )*/ column 1.....
    But still it does not use the index.Please suggest me some advice on this?
    Thanks

    user589320 wrote:
    I have a procedure which took 15-20 minutes in the past to execute.Suddently it is taking 2 hours.When i examined i came to know that the sql statement is not using one of the index.I dropped the index and created it.The explain plan is generated but still the index is not being used.I forced the index usage by using the index hint
    SELECT /*+ INDEX(test_his test_hist_idx )*/ column 1.....
    I think you're going to have to post the entire text of your query if you want an answer, or people will simply be trying to guess what you've done wrong.
    Do you also have the full execution plan from before and after the change in performance ?
    If you do post the text, and plans, please use the 'code' tags to make the text readable.
    p.s. My shot in the dark guess, based on the text you've supplied, is that you've used the table name in the hint, rather than the table alias.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The temptation to form premature theories upon insufficient data is the bane of our profession."
    Sherlock Holmes (Sir Arthur Conan Doyle) in "The Valley of Fear".
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Execution of subquery of IN and EXISTS clause.

    Hi Friends,
    Suppose we have following two tables:
    emp
    empno number
    ename varchar2(100)
    deptno number
    salary number
    dept
    deptno number
    location varchar2(100)
    deptname varchar2(100)
    status varchar2(100)
    Where dept is the master table for emp.
    Following query is fine to me:
    SELECT empno, ename
    FROM emp,dept
    WHERE emp.deptno = dept.deptno
    AND emp.salary &gt;=5000
    AND dept.status = 'ACTIVE';
    But I want to understand the behaviour of inline query (Used with IN and EXISTS clause) for which I have used this tables as an example (Just as Demo).
    1)
    Suppose we rewrite the above query as following:
    SELECT empno, ename
    FROM emp
    WHERE emp.salary &gt;=5000
    AND deptno in (SELECT deptno FROM dept where status = 'ACTIVE')
    Question: as shown in above query, suppose in our where clause, we have a condition with IN construct whose subquery is independent (it is not using any column of master query's resultset.). Then, will that query be executed only once or will it be executed for N number of times (N= number of records in emp table)
    In other words, how may times the subquery of IN clause as in above query be executed by complier to prepared the subquery's resultset?
    2)
    Suppose the we use the EXISTS clause (or NOT EXISTS clause) with subquery where, the subquery uses the field of master query in its where clause.
    SELECT E.empno, E.ename
    FROM emp E
    WHERE E.salary &gt;=5000
    AND EXISTS (SELECT 'X' FROM dept D where status = 'ACTIVE' AND D.deptno = E.deptno)
    Here also, I got same confusion. For how many times the subquery for EXISTS will be executed by oracle. For one time or for N number of times (I think, it will be N number of times).
    3)
    I know we can't define any fix thumbrule and its highly depends on requirement and other factors, but in general, Suppose our main query is on heavily loaded large transaction table and need to check existance of record in some less loaded and somewhat smaller transaction table, than which way will be better from performance point of view from above three. (1. Use of JOIN, 2. Use of IN, 3. Use of EXISTS)
    Please help me get solutions to these confusions..
    Thanks and Regards,
    Dipali..

    Dipali,
    First, I posted the links with my name only, I don;t know how did you pick another handle for addressing it?Never mind that.
    >
    Now another confusion I got.. I read that even if we used EXISTS and , CBO feels (from statistics and all his analysis) that using IN would be more efficient, than it will rewrite the query. My confusion is that, If CBO is smart enough to rewrite the query in its most efficient form, Is there any scope/need for a Developer/DBA to do SQL/Query tuning? Does this means that now , developer need not to work hard to write query in best menner, instade just what he needs to do is to write the query which resluts the data required by him..? Does this now mean that now no eperts are required for SQL tuning?
    >
    Where did you read that?Its good to see the reference which says this.I haven't come across any such thing where CBO will rewrite the query like this. Have a look at the following query.What we want to do is to get the list of all teh departments which have atleast one employee working in it.So how would be we write this query? Theremay be many ways.One,out of them is to use distinct.Let's see how it works,
    SQL> select * from V$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SQL> set timing on
    SQL> set autot trace exp
    SQL> SELECT distinct  D.deptno, D.dname
      2        FROM     scott.dept D,scott.emp E
      3  where e.deptno=d.deptno
      4  order by d.deptno;
    Elapsed: 00:00:00.12
    Execution Plan
    Plan hash value: 925733878
    | Id  | Operation                     | Name    | Rows  | Bytes | Cost (%CPU)| T
    ime     |
    |   0 | SELECT STATEMENT              |         |     9 |   144 |     7  (29)| 0
    0:00:01 |
    |   1 |  SORT UNIQUE                  |         |     9 |   144 |     7  (29)| 0
    0:00:01 |
    |   2 |   MERGE JOIN                  |         |    14 |   224 |     6  (17)| 0
    0:00:01 |
    |   3 |    TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     2   (0)| 0
    0:00:01 |
    |   4 |     INDEX FULL SCAN           | PK_DEPT |     4 |       |     1   (0)| 0
    0:00:01 |
    |*  5 |    SORT JOIN                  |         |    14 |    42 |     4  (25)| 0
    0:00:01 |
    |   6 |     TABLE ACCESS FULL         | EMP     |    14 |    42 |     3   (0)| 0
    0:00:01 |
    Predicate Information (identified by operation id):
       5 - access("E"."DEPTNO"="D"."DEPTNO")
           filter("E"."DEPTNO"="D"."DEPTNO")
    SQL>
    SQL> SELECT distinct  D.deptno, D.dname
      2        FROM     scott.dept D,scott.emp E
      3  where e.deptno=d.deptno
      4  order by d.deptno;
        DEPTNO DNAME
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
    Elapsed: 00:00:00.04
    SQL>So CBO did what we asked it do so.It made a full sort merge join.Now there is nothing wrong in it.There is no intelligence added by CBO to it.So now what, the query looks okay isn't it.If the answer is yes than let's finish the talk here.If no than we proceed further.
    We deliberately used the term "atleast" here.This would govern that we are not looking for entirely matching both the sources, emp and dept.Any matching result should solve our query's result.So , with "our knowledge" , we know that Exist can do that.Let's write teh query by it and see,
    SQL> SELECT   D.deptno, D.dname
      2        FROM     scott.dept D
      3          WHERE    EXISTS
      4                 (SELECT 1
      5                  FROM   scott.emp E
      6                  WHERE  E.deptno = D.deptno)
      7        ORDER BY D.deptno;
        DEPTNO DNAME
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
    Elapsed: 00:00:00.00
    SQL>Wow, that's same but there is a small difference in the timing.Note that I did run the query several times to elliminate the physical reads and recursive calls to effect the demo. So its the same result, let's see the plan.
    SQL> SELECT   D.deptno, D.dname
      2        FROM     scott.dept D
      3          WHERE    EXISTS
      4                 (SELECT 1
      5                  FROM   scott.emp E
      6                  WHERE  E.deptno = D.deptno)
      7        ORDER BY D.deptno;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1090737117
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Ti
    me     |
    |   0 | SELECT STATEMENT             |         |     3 |    48 |     6  (17)| 00
    :00:01 |
    |   1 |  MERGE JOIN SEMI             |         |     3 |    48 |     6  (17)| 00
    :00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     2   (0)| 00
    :00:01 |
    |   3 |    INDEX FULL SCAN           | PK_DEPT |     4 |       |     1   (0)| 00
    :00:01 |
    |*  4 |   SORT UNIQUE                |         |    14 |    42 |     4  (25)| 00
    :00:01 |
    |   5 |    TABLE ACCESS FULL         | EMP     |    14 |    42 |     3   (0)| 00
    :00:01 |
    Predicate Information (identified by operation id):
       4 - access("E"."DEPTNO"="D"."DEPTNO")
           filter("E"."DEPTNO"="D"."DEPTNO")Can you see a keyword called Semi here? This means that Oralce did make an equi join but not complete.Compare the bytes/rows returned from this as well as cost with the first query.Can you notice the difference?
    So what do we get from all this?You asked that if CBO becomes so smart, won't we need developers/dbas at that time?The answer is , what one wants to be, a monkey or an astranaut? Confused,read this,
    http://www.method-r.com/downloads/doc_download/6-the-oracle-advisors-from-a-different-perspective-karen-morton
    So it won't matter how much CBO would become intelligent, there will be still limitations to where it can go, what it can do.There will always be a need for a human to look all the automations.Rememember even the most sofisticated system needs some button to be pressed to get it on which is done by a human hand's finger ;-).
    Happy new year!
    HTH
    Aman....

  • PRC: Interface Usage and Miscellaneous Costs to General Ledger

    Urgent request
    We have the AP team that run the request PRC: Interface Usage and Miscellaneous Costs to General Ledger and it has been running for 2 hours+
    This report is run every month without any problems.
    Work Around: had end user cancel and resubmit request. Again taking awhile, it is still running.
    ANYONE WHO HAS RUN INTO THIS PROBLEM, PLEASE LET ME KNOW OF A SOLUTION. THANKS IN ADVANCE.

    are u using lower than 11.5.10.2, then i think you need to raise an SR with Oracle.
    Sometime back my client experinces this and raised an SR with Oracle ,and what i understood there is missing index on one of the underline table
    There was an issue with pa_bc_commitments table . Check out the Bug No. 7206084 on metalink.

  • High CPU Usage and Temperature

    I've recently purchased a MacBook with the latest updates, including the firmware for the random shutdowns but lately when I boot the MacBook up, the fans kick on and it reads 83 degrees Celsius with about 65% CPU Usage and I don't have anything running except what came on the MacBook in itself, any suggestions?? Apple told me to take it in to have it looked at but I was wondering if there is anything I can fix perhaps?? Thank you

    Sometimes when I connect an external drive which I have made drastic file changes to, there are two process that eat up a lot of cpu power and get the macbook really hot for awhile, those two processed are related to the way spotlight tries to re-index the external drive or the internal hd itself if I had made drastic changes to it too.
    Could it be that?
    You can see them show up in Activity Monitor, they are mdimport and another one starting with md(something) too.
    Hope that helps (if that's the issue)
    Best,
    Pedro

  • How can we find the most usage and lowest usage of table in Sql Server by T-SQL

    how can we find the most usage and lowest usage of table in Sql Server by T-SQL
    The table has time stamp column
    StartedOn datetime
    EndedOn datetime

    The Below query has been used , but the textdata column doesnot include the name of the table ServiceLog.
    SELECT
    FROM
    databasename,
    duration
    fn_trace_gettable('F:\Program
    Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\log_148.trc',
    default)
    WHERE
    DATABASENAME='ZTCFUTURE'
    AND TEXTDATA
    IS
    NOT
    NULL
    --AND TEXTDATA LIKE 'SERVICE%'
    order
    by cpu
    desc; 

  • No data in Usage and Standby?

    Hi,
    I have recently exchanged my white 16GB iphone at the local retail store, but have just noticed that since I exchanged it there does not seem to be any Usage figures in the general settings.
    By that I mean the "usage" and "standby" are blank, above the message "usage times will be shown after iphone is fully charged".
    To try and correct it, I reset the phone yesterday and it was on charge from 10pm last night to 7am this morning so I would have thought would be fully charged. (the battery meter appears to be fully charged)
    Is anyone else experiencing this problem or has any advice on how to correct it?
    Thanks for your help.

    When adding/creating an email account, the following presets are available.
    Exchange
    MobileMe
    Gmail
    Yahoo Mail
    AOL
    If you selected the Yahoo Mail account preset when adding/creating the account, the account was created as an IMAP account with Push access available for received messages along with an option to enable or disable Push access for the account.
    The data required to connect with the incoming mail server for an email account to check the incoming mail server for new messages is minute. More battery will be used the more often an account is checked for new messages, but this alone is not a significant battery drain and especially with a single email account. All server stored mailboxes with an IMAP account are not synchronized with the server when the account is checked for new messages. For example, the account's server stored Sent mailbox is not synchronized with the server until the account's Sent mailbox is selected.
    Push is not a constant fetch process. With an account that supports Push access for received messages, a new message received at the incoming mail server is "pushed" to the iPhone without the account having to be checked for new messages. In theory, Push access should use less battery compared to automatically checking the account for new messages, which isn't always the case and this also depends on the time interval set for automatically checking for new messages. You can have the account automatically checked for new messages every hour.
    Depending on how much data is accessed compared to the number and length of phone calls when roaming internationally, data access can be much more expensive.

  • Iphone 4 battery life draining battery usage and standby has (-) sign

    I know there are forums with the same question, however, I need to know what to do if the restore as new doesn't work as well as trying to turn off the notifications. My battery life was fine until I up graded to iOS5.0.1.
    I've also done a hard reboot tried to run the battery down and recharge to 100%. Nothing seems to work. I'm getting a usage and battery standby time of ( - ), no figures at all.
    With only 2 short calls and a couple of minutes of internet usage my phone has gone from 100% at 7h this morning to 70% at 11h36. I've only noticed the battery drain over the last few days. The only changes were a couple of upgrades on the apps and even deleting those aren't working. I've also tried to delete my email accounts. I've reinstalled the email settings not with exchange but through gmail. My notifications are at a minimum and iCloud is switched off, the only thing that it is backing are my contacts.
    Help! I travel far to get to work and need a reliable phone. I'm not sure whether to hold out for a new update on the software or take it to the genius bar.
    Any help would be appreciated.

    This seems to mainly affect the 4S however if you search the forum (hardware  and  using iPhone ) you will find many solutions that have either solved or dramatically improved the situation
    My  4 did playup  with 5.0.1  up but picking a selection  of the solutions has returned mine to normal
    Location Services to name but one

Maybe you are looking for