Not in and Not Exists

Hi everyone,
I need some explanation on why the index is not being used in one of my queries.
Here are the queries:
SELECT COUNT (1)
FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
FROM sm_vda_allocation_header hdr
INNER JOIN
sm_vda_type vdatype
ON hdr.vda_typ_cd = vdatype.vda_typ_cd
WHERE
vdatype.SAP_POST_TYP_CD = 'JE'
AND vdatype.vda_alloc_flg = 'Y'
AND hdr.vda_liab_flg IS NULL
AND hdr.sap_extrct_dt IS NULL
AND hdr.ALLOC_HDR_SEQ_NBR NOT IN
(SELECT alloc_hdr_seq_nbr
FROM sm_vda_allocation_detail));
return 0 rows.
explain plan::
Plan
SELECT STATEMENT CHOOSECost: 671 Bytes: 26 Cardinality: 1                          
     8 SORT AGGREGATE Bytes: 26 Cardinality: 1                     
          7 HASH JOIN Cost: 671 Bytes: 293,254 Cardinality: 11,279                
               1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7           
               6 MERGE JOIN ANTI Cost: 665 Bytes: 281,106 Cardinality: 15,617           
                    3 TABLE ACCESS BY INDEX ROWID SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 496 Bytes: 241,860 Cardinality: 20,155      
                         2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
                    5 SORT UNIQUE Cost: 169 Bytes: 417,480 Cardinality: 69,580      
                         4 INDEX FAST FULL SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 86 Bytes: 417,480 Cardinality: 69,580
2nd query::
SELECT COUNT (1)
FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
FROM sm_vda_allocation_header hdr
INNER JOIN
sm_vda_type vdatype
ON hdr.vda_typ_cd = vdatype.vda_typ_cd
WHERE
vdatype.SAP_POST_TYP_CD = 'JE'
AND vdatype.vda_alloc_flg = 'Y'
AND hdr.vda_liab_flg IS NULL
AND hdr.sap_extrct_dt IS NULL
AND NOT exists
(SELECT 1
FROM sm_vda_allocation_detail b where
hdr.ALLOC_HDR_SEQ_NBR = b.ALLOC_HDR_SEQ_NBR));
explain plan:::
Plan
SELECT STATEMENT CHOOSECost: 831 Bytes: 20 Cardinality: 1                     
     6 SORT AGGREGATE Bytes: 20 Cardinality: 1                
          5 FILTER           
               3 HASH JOIN Cost: 828 Bytes: 14,560 Cardinality: 728      
                    1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7
                    2 TABLE ACCESS FULL SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 822 Bytes: 12,096 Cardinality: 1,008
               4 INDEX RANGE SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 3 Bytes: 90 Cardinality: 15      
In the 2nd query with NOT EXISTS, I see FULL table scan for SM_APPL.SM_VDA_ALLOCATION_HEADER
In the first query, the index is used in the same place:
2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
ALLOC_HDR_SEQ_NBR is a primary key column.
Actually NOT IN and NOT EXISTS both used index for the second inner table (SM_APPL.SM_VDA_ALLOCATION_DETAIL).
But NOT exists is not using the index for the first table but not in is using.
how come.

872605 wrote:
Hi everyone,
I need some explanation on why the index is not being used in one of my queries.
Here are the queries:
SELECT COUNT (1)
FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
FROM sm_vda_allocation_header hdr
INNER JOIN
sm_vda_type vdatype
ON hdr.vda_typ_cd = vdatype.vda_typ_cd
WHERE
vdatype.SAP_POST_TYP_CD = 'JE'
AND vdatype.vda_alloc_flg = 'Y'
AND hdr.vda_liab_flg IS NULL
AND hdr.sap_extrct_dt IS NULL
AND hdr.ALLOC_HDR_SEQ_NBR NOT IN
(SELECT alloc_hdr_seq_nbr
FROM sm_vda_allocation_detail));
return 0 rows.
explain plan::
Plan
SELECT STATEMENT CHOOSECost: 671 Bytes: 26 Cardinality: 1                          
     8 SORT AGGREGATE Bytes: 26 Cardinality: 1                     
          7 HASH JOIN Cost: 671 Bytes: 293,254 Cardinality: 11,279                
               1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7           
               6 MERGE JOIN ANTI Cost: 665 Bytes: 281,106 Cardinality: 15,617           
                    3 TABLE ACCESS BY INDEX ROWID SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 496 Bytes: 241,860 Cardinality: 20,155      
                         2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
                    5 SORT UNIQUE Cost: 169 Bytes: 417,480 Cardinality: 69,580      
                         4 INDEX FAST FULL SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 86 Bytes: 417,480 Cardinality: 69,580
2nd query::
SELECT COUNT (1)
FROM (SELECT hdr.ALLOC_HDR_SEQ_NBR hdrnbr
FROM sm_vda_allocation_header hdr
INNER JOIN
sm_vda_type vdatype
ON hdr.vda_typ_cd = vdatype.vda_typ_cd
WHERE
vdatype.SAP_POST_TYP_CD = 'JE'
AND vdatype.vda_alloc_flg = 'Y'
AND hdr.vda_liab_flg IS NULL
AND hdr.sap_extrct_dt IS NULL
AND NOT exists
(SELECT 1
FROM sm_vda_allocation_detail b where
hdr.ALLOC_HDR_SEQ_NBR = b.ALLOC_HDR_SEQ_NBR));
explain plan:::
Plan
SELECT STATEMENT CHOOSECost: 831 Bytes: 20 Cardinality: 1                     
     6 SORT AGGREGATE Bytes: 20 Cardinality: 1                
          5 FILTER           
               3 HASH JOIN Cost: 828 Bytes: 14,560 Cardinality: 728      
                    1 TABLE ACCESS FULL SM_APPL.SM_VDA_TYPE Cost: 5 Bytes: 56 Cardinality: 7
                    2 TABLE ACCESS FULL SM_APPL.SM_VDA_ALLOCATION_HEADER Cost: 822 Bytes: 12,096 Cardinality: 1,008
               4 INDEX RANGE SCAN NON-UNIQUE SM_APPL.SM_VDA_ALLOCATION_DETAIL_FK_I Cost: 3 Bytes: 90 Cardinality: 15      
In the 2nd query with NOT EXISTS, I see FULL table scan for SM_APPL.SM_VDA_ALLOCATION_HEADER
In the first query, the index is used in the same place:
2 INDEX FULL SCAN UNIQUE SM_APPL.SM_VDA_ALLOCATION_HEADER_PK Cost: 438 Cardinality: 20,450
ALLOC_HDR_SEQ_NBR is a primary key column.
Actually NOT IN and NOT EXISTS both used index for the second inner table (SM_APPL.SM_VDA_ALLOCATION_DETAIL).
But NOT exists is not using the index for the first table but not in is using.
how come.WHY MY INDEX IS NOT BEING USED
http://communities.bmc.com/communities/docs/DOC-10031
http://searchoracle.techtarget.com/tip/Why-isn-t-my-index-getting-used
http://www.orafaq.com/tuningguide/not%20using%20index.html

Similar Messages

  • Not distributued and Not included issues.

    We have a couple of issues with Not distributed and Not included issues. First, since they are commingled with our variances they do not get passed through to PA so we are off between GL and PA. Second, the not distributed are not part of inventory since they  remain in the variance account.
    Anyone have experience with these and any solutions for these issues?
    SAP says we can turn off the price delimiter but we are uncertain as to the effect overall.
    Anyway to isolate these to a different GL account posting?

    <b>Solution</b>
         **<b>'Not distributed'</b> price differences can be due to three reasons:
         <b>A)</b> System applied a 'Price limiter' logic (stock coverage check).
         You can analyse this case using the value flow monitor transaction:
             - for release 4.7 , transaction CKMVFM
             - for release  4.6C,  program SAPRCKM_VERIFY_PRICE_DET (note 324754 is required).
             - for release  < 4.6C: Program ZVERIFY_PRICE_DET  included in the note 324754 Or  directly checking the field CKMLPP-PBPOPO manually.
         In this case, the value field CKMLPP-PBPOPO > cumulative inventory.
         If you still want these price differences to be distributed , you can switch off price limiter logic. Then all price differences are posted to stock, and the price difference account is cleared. You should  decide
         for each material if you want to switch off price limiter logic or not.
         So you can achieve a compromise between realistic prices and clearing
         the balance of the price different account.
         Price limiter logic can be switched off in the following way:
    Resetting the price limiter quantity:
              In release 4.7 this is done uising transaction CKMVFM.
              In release <= 46C using the    ZREMOVE_PRICE_LIMITER (see note 325406).
    Note 855387:
              Application of this note will create an additional selection parameter for step 'Single Level Price Determination' to switch on/off price limiter logic.
              This option is the better way, as it is faster provides more flexibility (see the note for more information).
         <b>B)</b> System applied a fallback strategy during price determination
         (see note 579216) to avoid a negative periodic unit price (PUP).
         Please check the attached  note 579216:
         If the regularly calculated PUP (based on  'Cumulative Inventory' line) would become negative, the system uses a different strategy to calculate the PUP:
         The PUP is calculated with these priorities:
         1.'Cumulative Inventory' line (no fallback)
         2.Receipts ('ZU') line  (Info message C+ 135 in the log)
         3.Beginning inventory ('AB') line  (Info message C+ 135 in the log)
         4.PUP-price of previous period (Info message C+ 136 in the log)
         5.S-price (->(Info message C+ 137 in the log)
         The fallback strategy is active by default for Single-Level price determination.
         For multilevel price determination it must be activated with parameter 'Negative price: automatic error management'.
         As a solution, you might check the postings of these materials if they really need to have such big negative price differences or if there is some kind of error in the posting or the production structure
         If you find such errors, you might reverse the corresponding postings and report them in a correct way.
         Or, you might use transaction MR22 (debit/credit material) in order to post a small positive amount of differences to the concerned materials
         so that the resulting actual price would no longer be negative. Then you could perform the period closing (which you had to reverse before).
         In the next period, you might remove this manual posted value from the materials (again with MR22) in order to correct the overall stock values back to their original amounts.
         <b>C)</b> Due to a source code error with transaction CKMM.
         The above situation may be produced because transaction CKMM was executed during the corresponding period.
         When transaction CKMM is processed the system deletes the price differences for the material in the period and these differences are not longer in the period record tables.
         See note 384553 for further details.
         The fact is that the price differences are still visible in CKM3 (as not distributed). This is due to the missing reset of summarization records (MLCD).
         This error is just a problem of CKM3 display, because the differences shown as 'not distributed' do not exist in the periodic records. The PUP of the material is calculated correctly.
         This error is corrected by note 838989 for the future.

  • Excise invoice is not saving and not showing datas

    in erxcise invoice i ve made settings as per the sap best practices then also the excise invoice is not saved and not generated also
    please help me to solve the problem
    the error is coming like this
    Error in allocating Excise invoice number Interval not found Number object J_1IEXCLOC
    Message no. 8I336
    i ve already maintainthe number range for this object in tool in tax in goods moment
    please give some better advice for the excise invoice setting.

    Sub Transaction type determines the subcontracting attributes and determines the accounts for the posting while doing a sub contracting transaction.
    Sub transaction type is also used for determining the accounts while
    doing excise removals.
    Within CIN the account determination is based on the transaction type.
    So normally you can have a single set of accounts for Excise
    utilization. In case you need alternate account determination for
    handling various scenarios you can define sub transaction types. The
    sub transaction types and corresponding account assignments needs to be
    maintained in CIN customization
    To make customization of Sub Transaction type, goto
    <b>SPRO --> Logistics General --> Tax on Goods Movements --> India --> Account Determination and check whether you have assigned second and third one, viz. "Specify Excise Accounts per Excise Transaction and Specify GL Accounts per Excise Transaction".</b>
    Check
    <b>Taxes on goods mvnt--indiaaccnt determination---specify excise accnts for excise transaction...maintain the sub transction type , ip or 01,
    against the appropriate ETT</b>
    Message was edited by:
            sam masker

  • HT1766 # is not working in my iphone 4s, when i want to see how much credit i have in iphone, i need to put # on that, than it calls and end, it is not working and not showing anything..

    # is not working in my iphone 4s, when i want to see how much credit i have in iphone, i need to put # on that, than it calls and end, it is not working and not showing anything..

    http://support.apple.com/kb/HT1848  Did you transfer your purchased item, take a look at the link

  • IPod stuck in "do not disconnect" and NOT recognized by iTunes

    I updated to 7.1.1.... and my iPod is not stuck in "do Not disconnect" and not recognized by iTunes.
    I have tried the Toshiba "Safely Remove Hardware" -- and selecting the iPOD -- but, notice comes back "cannot disconnect now because a program is accessing the device."
    Anyone know where I can go from here??? Thanks very much.

    the same thing happened to me yesterday after downloading the new itunes 7.1.1 the do not dissconnect would'nt go off and computer and itunes would'nt reconize my ipod video.
    so i left it alone overnight to empty battery completely.
    the do not disconnect was gone in the morning then i recharged it and plugged it back in to computer and everything is fine. i don't know why it froze on me.
    my husbands ipod mini had a similar problem awhile back and i did the same and it also was fine.

  • My wireless keyboard no longer connects with my iMac since changing the batteries. It now shows as not connected, not paired and not configured. A friend recently connected his iPad to the iMac and since then the problem started. Any ideas to resolve this

    My wireless keyboard no longer connects with my iMac since changing the batteries. It now shows as not connected, not paired and not configured. A friend recently connected his iPad to the iMac and since then the problem started. Any ideas to resolve this?

    a friend told me that he wants my os x cd for my macbook pro to upgrade his imac.
    The discs that come with your Mac are "machine specfic" and cannot be used on another Mac.

  • TS1398 when i update my software to 6.1.3(10B329)to I phone 4s the wifi is not working and not auto join the network that i have already connected to

    when i update my software to 6.1.3(10B329)to I phone 4s the wifi is not working and not auto join the network that i have already connected to

    First, grow up.  Just because YOUR phone isn't working, doesn't mean Apple put out bad software.  I've not had any difficulty, nor has anyone else I know.  And just how is Apple risking lives with Bluetooth kits not working?  It's YOUR decision to talk on the phone or text and drive.  Not Apple's.
    We're users here, volunteering our time to help others.  Posts like yours, which are whiny and ranting, simply means we're likely to ignore you and not provide you with any help.  Not to mention, it makes you look absolutely foolish.
    Further making you look foolish is the fact that you haven't even asked a technical support question, nor have you provided anyone here with any troubleshooting steps you might have taken, including those recommended in the user guide.
    Good luck getting help.
    GDG

  • I recently had to wipe my hard drive thanks to a download happy teen. In that process I lost my LR4 catalogs I was able to redownload the program but the catalogs are not there and not all of those pictures are on my external hard drive because same said

    In that process I lost my LR4 catalogs I was able to redownload the program but the catalogs are not there and not all of those pictures are on my external hard drive because same said teen decided they were going to borrow my external hard drive without telling me and "made room" on it. Is there a way to recover my catalogs? Please tell me there is because I was in the middle of working on a session when I had to wipe my drive and I would REALLY like to not have to go back and reshoot it. Any help would be wonderful!

    It depends on how you wiped your drive.  Depending on how you did it, only the directory was erased and the data can be found with drive recovery software.  Some are free, although there is a small charge for most of them (~$30).  You can usually download a trial version that shows if it will work and you have to pay to be able to save the found files.  Use Google to search for the software.  Different programs work differently and can find different things.
    Good luck.
    John

  • My ipad 2 died. It is not charging and not working. Help?

    My ipad 2 has suddenly died. It is not charging and not working. It is under the one year warranty. Does anybody have experienced such problem?

    If you are stuck with the Apple logo then the last section on this page http://support.apple.com/kb/TS3281 suggests putting the iPad into recovery mode http://support.apple.com/kb/HT4097 (which so far I havn't need to do with mine)

  • My iphone 4 is saying every action. when we touch enything it repeats that action. and it is not unloking. and not shutdown.

    my iphone 4 is saying every action. when we touch enything it repeats that action. and it is not unloking. and not shutdown.

    Check your acessiblity settings, is voiceover turned on?
    Settings > General > Acessibility > Voice Over

  • Podcasts episodes not visible and not updated

    Since 2 weeks I have noticed that in iTunes for Windows new postcasts episodes are no longer visible in the Postcast section. The result is that as no updates are shown (also not after using the refresh option) the new episodes are not downloaded either.
    The strange thing is that when I look in the iTunes Store or create a Smart playlist with Grouping set to Podcast the episodes are visible.
    Any suggestions why the episodes are not visible and not updated?
    Thanks.

    Does this fit your situation? iTunes will stop updating a podcast subscription if you have more than five episodes downloaded but not listened to, as detailed in this page:
    http://support.apple.com/kb/TA23353
    which states:
    You've subscribed to a podcast but have more than five unplayed episodes. iTunes will stop automatically downloading newer episodes. You may get the following message:
    iTunes has stopped updating this podcast because you have not listened to any episodes recently. Would you like to resume updating this podcast?
    You can click Yes to continue downloading additional episodes. Or you can just listen to any part of any episode and a new episode will download at the next update.

  • APs showing 'not associated' and 'not registered' in PI 2.1

    I have got a weird issue in PI 2.1.0.0.87.
    WiSM2, running on version 7.4.121.21, shows reachable and managed/synchronized in PI. However, the APs managed by it show 'controller IP->not associated' and 'not registered'. It is been confirmed that the SNMP/TELNET/HTTP creds are correct and all the APs in question are showing fully operational in WLC. When the user trying to delete the entry in PI, it always failed without any messages.
    Any ideas why it happens?
    Thanks!

    Remove the controller and add again, see if the APs are reflected then
    Troubleshoot using:
    http://www.cisco.com/c/en/us/td/docs/net_mgmt/prime/infrastructure/1-2/user/guide/prime_infra_ug/troubleshootaps.html

  • Need help FLASH not launching and not uninstalling "licensing for this product has stopped working".

    Need help FLASH not launching and not uninstalling "licensing for this product has stopped working" and " you can only install one adobe product at a time please complete the other installation"  Flash was working absolutely fine before, I have no idea why this happened.

    I am having similar problem.  Can't open any of CS3 programs after trying to download Dreamweaver Trial, which wouldn't work because "couldn't remove DLM extention" error message.  So now I can not run Illustrator, Photoshop, or even Adobe Reader.  These are properly licensed for about a year. I get "License for product has stopped working".  Have 2 pending cases open with Adobe support (one for Dreamweaver trial, one for license problem) since 8/3 with NO ANSWERS - It says answers within 1-3 business days.  Was on phone support hold today for over 3 hours before line went dead with no help.  What is up with adobe support?  Can anyone help?

  • SMICM indicates J2EE status as not configured and not started

    I am running WAS6.40 with J2EE add-in. Until recently the J2EE was working fine. Was able to access it using http://<hostname>:50000/  but recently it stopped working. There is nothing obvious in the logs & traces. SMICM indicates J2EE status as not configured and not started. Where else can I look for? How do I increase trace level?

    Can you be more specific? Which logs and traces did you look at?
    The default trace, dispatcher/server logs should indicate what happened (and they should also be written to during a restart)....
    Also check the std* files in your work directory...

  • Day after yesterday night, my iphone 4s full off, I don't know why? but not oppen and not charging. What do I do?

    Day after yesterday night, my iphone 4s full off, I don't know why? but not oppen and not charging. What do I do?

    Plug it in to power for at least 15 minutes.  If it doesn't automatically come on, try a Reset... press the home and sleep/lock buttons until you see the Apple logo, ignoring the slider. Takes about 5-15 secs of button holding and you won't lose any data or settings.

Maybe you are looking for

  • Setting up owa in mail and calendars

    just wondering if anyone can help on what the settings for an Exchange account has to be? i have mail working fine on the iPhone, but not in Mail or Calendars on Mavericks In Internet Accounts in the System Pref. i have simply put email as [email pro

  • How do I get old OS back

    Updated my 9700 to the 6 bundle and hate it.  How do I get me old operating system back Any help would be appreciated. Skeets Solved! Go to Solution.

  • Problems trying to erase and install osx mavericks

    Hi all, so ive just bought an imac off my parents and have tried to do erase system, I have erased the macintosh hd as i am supposed but when it comes to re-installing the os x and I sign into the app store to start downloading i get an error saying

  • Webapp help

    I'm preparing to write my first big web application, and now I have problem, which technology I should use. Many people suggest using spring, but when I searched the web, I noticed that sun lunched new standard (ejb3, jpa, jee5). Which solution is be

  • Mac OS 10.2

    Is there anyway of making my ipod 5.5 (late 2006) work with mac os x 10.2 because as far as i know you have to have mac os 10.3 thanks please replay asap