Index usage problem..

I got an requirement stating to get a max value of column b for given value for column a. Since to avoid a table scan, I created a composite Index on (a, b).
I tried with the query
select max(b) from table where a = invalue
Since the index is already been sorted the max(b) for value of a should be direct. But the explain plan for this query says, a range scan on the index and a sort and then the output of value.
But I like to have a single row fetch directly. Pls help me in modifying the query to get the max value directly without any scans.
Thanks
Suriya.

I'm not sure whether it is work, but you can try :
(1) Using single select statement
select x.b
from ( select b from table
where a = invalue
order by b desc
where rownum = 1;
OR
(2) PL/SQL program
begin
for c1rec in ( select b from table
where a = invalue
order by b desc ) loop
dbms_output.put_line(c1rec.b);
exit;
end loop;
end;
null

Similar Messages

  • 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

  • '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

  • I'm trying to resolve a battery usage problem

    I'm trying to resolve a battery usage problem on my iPhone 5S ...
    Have been working with an Apple agent via chat and I'm 99% certain it's a software problem, but I can't isolate wish software ...
    So, I'm going to set up my iPhone up as new (when I did this as part of identifying where the problem is, it help its charge for 24 hours) but I have a problem with photos ...
    I can see photos on my iPhone (restored from an iCloud backup) up to date, but on my iMac/iPhoto with my iPhone attached i) I can only see photos on my iPhone up to a date in the past (mid October 2014) and ii) iPhoto says all photos have already been imported ...
    How can I (can I) get the more recent photos onto my iMac e.g. into a folder and then import them from there into iPhoto?
    Also, why is the restore from an iCloud backup taking so long (it's been 14 hours now) when I'm pretty certain everything's now there that should be?

    Just to add ... my real problem is that I can see photos on my iPhone, but in iPhoto with the iPhone connected, I can only see photos up to a certain date - weird?!!!

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Indices configuration for XML document analysis (indexing time problems)

    Hi all,
    I'm currently developing a tool for XML Document analysis using XQuery. We have a need to analyse the content of a large CMS dump, so I am adding all documents to a berkeley DB xml to be able to run xqueries against it.
    In my last run I've been running to indexing speed problems, with single documents (typically 10-20 K in size) taking around 20 sec to be added to the database after 6000 documents (I've got around 20000 in total). The time needed for adding docs to the database drops with the number of documents.
    I suspect my index configuration to be the reason for this performance drop. Indeed, I've been very generous with indexes, as we have to analyse the data and don't know the structure in advance.
    Currently my index configuration includes:
    - 2 default indicess: edge-element-presence-none and edge-attribute-presence-none to be able to speed up every possible xquery to analyse data patterns: ex. collection()//table//p[contains(.,'help')]
    - 8 edge-attribute-substring-string indices on attributes we use often (id, value, name, ...)
    - 1 edge-element-substring-string index on the root element of the xml documents to be able to speed up document searches: ex. collection()//page[contains(.,'help')]
    So here my questions:
    - Are there any possible performance optimisations in Database config (not index config)? I only set the following:
    setTransactional(false);
    envConf.setCacheSize(1024*64);
    envConf.setCacheMax(1024*256);
    - How can I test various index configuration on the fly? Are there any db tools that allow to set/remove indexes?
    - Is my index config suspect? ;-)
    Greetings,
    Nils

    Hi Nils,
    The edge-element-substring-string index on the document element is almost certainly the cause of the slow document inserts - that's really not a good idea. Substring indexes are used to optimize "=", contains(), starts-with() and ends-with() when they are applied to the named element that has the substring index, so I don't think that index will do what you want it to.
    John

  • Index Usage in 9i changed  when used rownum

    Hi List,My Application is in RBO
    Here is one more brain twister ?
    Assume following I Have table SHRI with a single column
    COL I have created Index on COL column say IND_COL.
    Now when I run Following query on 8i with AUTOTRACE ON
    I can see that 8i Uses the Index IND_COL Clearly .
    select * from shri where (h_name='ABC' or h_name='BOM')
    or (h_name ='BOM' or h_name='MOM')
    and rownum=1
    select * from shri where (COL='ABC' or COL='BOM')
    or (COL='ABC' or COL='BOM')
    and rownum=1
    (Note:Above example is just for ur understanding plz.dont see the usage)
    Now my problem is when I see the explain plan for above query in 8i I can see that Query uses IND_COL .
    But when I run the same in 9i It does not uses IND_COL Index (Strange!!!) .
    However when I remove "and rownum=1" clause then It again uses the index in 9i.
    Assume that such queries are existing many places .
    I am badly stuck because of this problem can anybody suggest the best way (Other than changing RBO to CBO) ?
    Regards
    Sripad.

    Run below query, you will get all the details of tablespaces.
    col "Tablespace" for a22
    col "Used MB" for 99,999,999
    col "Free MB" for 99,999,999
    col "Total MB" for 99,999,999
    select df.tablespace_name "Tablespace",
    totalusedspace "Used MB",
    (df.totalspace - tu.totalusedspace) "Free MB",
    df.totalspace "Total MB",
    round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))
    "Pct. Free"
    from
    (select tablespace_name,
    round(sum(bytes) / 1048576) TotalSpace
    from dba_data_files
    group by tablespace_name) df,
    (select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_name
    from dba_segments
    group by tablespace_name) tu
    where df.tablespace_name = tu.tablespace_name ;

  • Iphone 5 - anyone having huge cellular data usage problem on ATT

    I upgraded from Iphone 3g to Iphone 5. Over a period of last year, My average monthly data usage is approx 400MB (total less than 5GB in a year). AT&T is reporting that my Iphone 5 data usage crossed 6GB in a 3 day period . I called AT&T and have to listen to LTE, Iphone 5 and Multiple app running in background  non-sense as an explanation for 6GB data usage over a 3 day period. My Itune and app store does not download over cellular network. Even though Iphone 5 automatically creates an Icloud account during initial setup, I am not connected to Icloud on Iphone and never even logged on to Icloud account. IOS 6 setting for sending data diagnostic over cellular network is set to no.
    I feel this is same bug which Verizon user are reporting and ATT is not commenting on it till now. How can I consume over 6GB worth of data over a 3 day period which is more than my total data usage for a year. That is equivalent of streaming hd video (approx 300 MB per hour) for 20 hours.
    CNN link to Iphone 5 data bug story
    http://money.cnn.com/2012/10/01/technology/iphone-​5-data-overage/index.html
    Anyone is having similiar problems?

    There have been lots of discussions about this particular topic
    https://discussions.apple.com/message/19398807#19398807
    https://discussions.apple.com/message/19780554#19780554
    https://discussions.apple.com/message/19802173#19802173
    and the list goes on.
    Apple has zero control over what AT&T does in regards to their plans for data, their charges for data, or anything to do with their service that you pay for every month

  • Windows 8.1 100% Disk Usage Problem

    I am running a Toshiba Satellite C855D-S5110. 12 GB Ram, 456 GB HD with 311 GB free, CPU Max speed 2.7 GH. My computer, as many other
    W8 and W8.1 users seem to suffer, is nearly constantly at 100% disk usage (apparently
    I have seen many claims as to what causes this; some even say it involves a bad HD. However, I do not think my HD is bad because
    1. My HD was fine before I got 8.1, to the best of my knowledge ( was on 8 prior to 8.1)
    2. Most importantly, when my computer isn't in the 100% phases, it seems to work absolutely fine!
    I would like help in figuring out what to do about this problem, as well as why it occurs and why it works the way it does (i.e. seemingly just going away for long periods of time).
    It is extremely difficult to work when my computer is being very slow, and not knowing when it will happen or what makes it stop happening is frustrating.
    I will provide below a list of measures I have taken, edited to include new things tried.
    1. Adding RAM
    2. Increasing pagefile
    3. Running programs to clean up clutter, fix registry problems, free up memory, etc (specifically, Iolo System Mechanic)
    4. Disabling the Windows Search Indexing service
    5. Checking for updates
    6. Running Microsoft Security Scanner (it found nothing)
    7. Disabling Live Tiles (of which I only had one in the first place!)
    8. One person claimed that their problem went away when they ran Skype, of all things. I tried this, though it did not do the trick.
    9. Booting in Safe Mode.
    10. Clean Boot.
    11. My drive is 0% fragmented.
    12. Trying to repair the Windows Image does nothing, as it comes up as being healthy when scanned.
    13. sfc /scannow did not fix the problem either.
    14. Running Microsoft's performance scanner and uploading the .etl file got me a reply blaming Chrome, which is impossible because
    the problem occurs with no programs running. I will try another recording and put it up; the link will be edited in.
    https://skydrive.live.com/redir?resid=DD4BA6A3F312AE94!945&authkey=!APrxfxQeNw14igc&ithint=file%2c.etl

    Having the exact same problem on a computer after the Windows update installed from 8.0 to 8.1. 
    Even after reloading the computer  from scratch.
    The drive activity goes WAY up when booting  - to 100%.  It then seems to calm down but randomly will go up and down throughout the day peaking at 100%. Even when nothing is open except a MSWord page into which  I am typing.
    If other programs are open such as Excel and/or Internet Explorer they will display the file name at the top as usual with (Not Responding) at the end. The screen will fade to an opaque look. This lasts for up to approx. 15 minutes at times and the computer
    responds to no keyboard or mouse clicks. The mouse pointer on the screen still moves but nothing happens when I click on anything.
    I managed to keep the Task Manager visible and it clearly shows less than 20% memory use and less than 5% CPU use when this occurs. But the HDD is at 100%.
    The fact that it was fine prior to updating to 8.1 indicates an issue with 8.1 to me. Absolutely nothing else has changed on this machine - aside from Windows Update.
    This is a know fault and I hate W8.1. Once it finishes whatever it is doing then there are a bunch of screen flashes as it catches up to what ever and where ever I had clicked with the mouse while it was frozen. It is like it is catching up because W8.1
    is causing the HDD to ???????????
    Another issue I encounter is the stupid Automatic Maintenance that cannot be disabled. I have found nothing to accomplish this that actually works no matter what anyone has posted on MS sites. It last rendered my computer today useless for approx. +1
    hour today!!! I had been using the computer and it was never idle for more than 1 or 2 minutes but yet it started. It is set to run at 1:00 am but it was only approx. 5:00 pm.!!
    The Automatic Maintenance is not running however, when the computer freezes and uses 100% HDD as indicated by Task Manager.
    Also I can disconnect the computer from the modem or power off the modem and the HDD remains at 100%! So it is not sending nor receiving anything at that time.

  • Index Usage

    Hi All,
    Using Oracle 11.2.0.3 on a TEST server
    create index emp_job_sal_idx on emp(job,sal) ;
    SQL> create or replace view test1 as select d.deptno, d.dname, e.empno, e.job, e.sal from dept d, emp e where d.deptno=e.deptno and
    (e.job='CLERK' and e.sal > 1000) OR
    (e.job='ANALYST' and e.sal >= 3000) OR
    (e.job='SALESMAN' and e.sal >=1500);
    SQL> set autotrace on explain
    SQL> select * from test1;
    18 rows selected.
    Execution Plan
    Plan hash value: 4192419542
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time       |
    |   0 | SELECT STATEMENT   |       |     1 |    67 |    10   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS        |       |     1 |    67 |    10   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| DEPT |     4 |    88 |     3   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |     1 |    45 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------The index is not used, mostly due to a OR condition. How can we make the index use without using hints ?

    sb92075 wrote:
    post EXPLAIN PLAN for problem SQL
    Execution Plan
    Plan hash value: 3466901445
    | Id  | Operation          | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |             |     1 |   331 |   383K  (7)| 01:16:40 |
    |*  1 |  HASH JOIN         |             |     1 |   331 |   383K  (7)| 01:16:40 |
    |*  2 |   TABLE ACCESS FULL| ENT_TRAN|     1 |   165 |   205K  (9)| 00:41:07 |
    |   3 |   TABLE ACCESS FULL| ENT_MAST         |    19M|  3111M|   177K  (3)| 00:35:31 |
    1 - access(NLSSORT("ENT_MAST"."ID",'nls_sort=''BINARY_CI''')=NLSSORT(
                  "ENT_TRAN"."RID",'nls_sort=''BINARY_CI'''))
       2 - filter(NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI'''
                  )=HEXTORAW('616D616E616820736168616D206E6173696F6E616C2062657268616400')
                  AND NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('343
                  73435377600')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_C
                  I''')=HEXTORAW('74656E616761206E6173696F6E616C2062657268616400')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3230303
                  836367700')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI'
                  '')=HEXTORAW('74656C656B6F6D206D616C61797369612062657268616400')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3132383
                  734307000')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI'
                  '')=HEXTORAW('6167726F2062616E6B00')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3831313
                  831307500')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI'
                  '')=HEXTORAW('6272756365206C656520796565206C616D00')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3530333
                  333373100')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI'
                  '')=HEXTORAW('616B6261722074726164696E6700')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3030313
                  438383037397500')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINA
                  RY_CI''')=HEXTORAW('372D656C6576656E206D616C61797369612073646E2062686400')
                    AND NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3
                  132303936327000')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINA
                  RY_CI''')=HEXTORAW('6368616E20796F6B65206368656E6700')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3637303
                  532372D30362D3534393600')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sor
                  t=''BINARY_CI''')=HEXTORAW('646B7368206D616C61797369612073646E2062686400')
                    AND NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3
                  030343437367500')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINA
                  RY_CI''')=HEXTORAW('626574746572207B267D206265737420656E746572707269736500
                  ')  AND NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW(
                  '3030313632353132347000')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sor
                  t=''BINARY_CI''')=HEXTORAW('6C696D20656E672073696F65206A756E6B657400')
                  AND NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('743
                  5353138393300')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY
                  _CI''')=HEXTORAW('712E712E206A756E6B657400')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('7331373
                  233363200')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI'
                  '')=HEXTORAW('6572206B696D206B656F6E6700')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3539303
                  932302D31302D3538333700')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sor
                  t=''BINARY_CI''')=HEXTORAW('726963686C616E64206C6569737572652067726F757000
                  ')  AND NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW(
                  '3538303532382D30312D3539383500')  OR
                  NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('74
                  69656E2079756E20656E74657270726973652073646E2E206268642E00')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3637303
                  332382D31302D3534363700')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sor
                  t=''BINARY_CI''')=HEXTORAW('73686172696B617420686F636B2068696E00')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3030303
                  234323136397000')  OR NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINA
                  RY_CI''')=HEXTORAW('6D7964696E206D6F68616D656420686F6C64696E67732062686420
                  28666F726D65726C79206B6E6F776E206173206D7964696E206D6F68616D656420686F6C64
                  696E67732073646E206268642900')  AND NLSSORT("ENT_TRAN"."PP_NO",'nls_so
                  rt=''BINARY_CI''')=HEXTORAW('3232313434386100')  OR
                  NLSSORT("ENT_TRAN"."NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('65
                  7665726973652076656E74757265732073646E2062686400')  AND
                  NLSSORT("ENT_TRAN"."PP_NO",'nls_sort=''BINARY_CI''')=HEXTORAW('3239353
                  137377000')  OR NLSSORT("EN)
    Statistics
              1  recursive calls
              0  db block gets
        1353887  consistent gets
        1353339  physical reads
              0  redo size
        1204784  bytes sent via SQL*Net to client
           4989  bytes received via SQL*Net from client
            408  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           6092  rows processed
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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.

  • Index usage making SQL slower.

    Hello,
    While working on a performance tuning activity on Oracle 10.2.0.4 on Solaris 10, I encountered a problem wherein one of our DBA's suggested indexing 2 columns of a certain table. One of the queries which is being run on that table has a RULE hint, and it is seen to be making use of this newly created index. Before the index was created, this query was running fine and getting completed within 30 mins or so. However after the index is created, it is now taking 12 hours on average to complete. Please note that in both the above cases, the CURSOR_SHARING parameter was set to EXACT. Yes, after the index was created its statistics were computed, and for both the index and the base table statistics were gathered. The query is making use of bind variables and is being run via the SQR engine of PeopleSoft.
    Please advice what can be the possible reasons for such delays being caused?
    For any information, please let me know and I would provide the same in this forum/
    Note for moderators: I could not find the section for Performance tuning, so I am asking this question in the general forum. Apologies.
    Thank You,
    Prashant.

    Index scans are not always faster.
    Full table scans are not always bad.
    I doubt that the RULE hint is necessary.
    In general, [url http://www.centrexcc.com/Tuning%20by%20Cardinality%20Feedback.pdf]the CBO does an excellent job of finding the best access plan for a given sql provided it is able to accurately estimate the cardinalities of the row sources in the plan.
    See advice and information required in the template tuning threads:
    [url https://forums.oracle.com/forums/thread.jspa?threadID=863295]How to post a sql tuning request
    [url https://forums.oracle.com/forums/thread.jspa?messageID=1812597]When your query takes too long

  • 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 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

  • High memory usage problem

    Firefox regularly creeps up to about 350 mb of memory usage. It runs poorly, crashes, etc. I read some other posts about how to reduce the its memory usage via about:config tweaks. I made adjustments to browser.cache.disk.capacity (was set to over 1,000,000, reduced to 50,000) and config.trim_on_minimize. However, memory usage has not decreased. I also see the value browser.cache.disk.smart_size_cached_value;1048576. I changed this to 50,000 also, but it reverts to the original number after every restart.
    I have 3 tabs open right now (Hotmail, Google, and this page) and memory is at 242,000.
    I should also note that I recently reformatted my hard drive. Firefox has almost no extensions or plug-ins installed (other than things like Flash and Silverlight). I'm running Windows 7 64-bit, and have 6 gb of RAM.
    Any suggestions for alleviating this problem would be greatly appreciated.

    235 to 285 MB seems to be a rather low notification threshold on a PC that has 3GB installed, not even 10% of RAM being used and that message is triggered.
    That's a new feature in AVG, and I suspect it might need a little tweaking. Unfortunately AVG didn't seem to provide any user adjustments into that feature, so the best thing to do is turn it off if that warning message appears too often.
    Here's an AVG support thread where the users says he gets that message with IE, Chrome, and Firefox. <br />
    http://forums.avg.com/us-en/avg-forums?sec=thread&act=show&id=180124

Maybe you are looking for

  • Urgent: JAAS Login Module Deployment Problem

    Hi, I have developed a JAAS Login module for the portal (EP6 SP9 sneak preview) and i am getting the following error: GroupAssignmentLoginModuleLibrary does not exist in LoadContextWrapper.modifyName. com.sap.engine.services.security.exceptions.BaseS

  • No audio on import of DV files with imovie 10.0

    Just installed the new iMovie 10.0 and imported all of my projects and events.  Clips that were in the DV format appear to have no audio track and the ability to adjust track speed is ghosted.  I have imported new DV files manually with the same resu

  • Won't sleep with 2 monitors

    Hi My G4 GE will not sleep when I have dual monitors connected. I have the stock AGP Rage Card with a Sony CRT. And I have an additional PCI Rage card with an Apple Studio Display. When the second monitor is connected, the mac will not go to sleep. (

  • Problems with switch from Windows to Mac

    I recently switched from Windows PC to a new Mac and cannot install the Acrobat 7.0 Professional CD that I used with Windows on the Mac. Am I missing something, or do I need to buy a whole new product?

  • Sync iphone to macbook

    I just got a brand new MacBook. I am trying to sync all the information I have in my Iphone, I open Itunes, plug the phone to the computer, from the Itunes screen I click sync and doesn't transfer the information I have in my Iphone to the MacBook. W