Trying to optimize the following update query

I am trying to update a table based on the values of another table in the following manner. I have two tables A and B. Say A has 300,000 records and B has 100,000 which is basically a set of the 300,000 in A. Therefore, B has the exact same records as A. There are two columns in both tables (status and my_status). Currently for all the records in A these two values are 0 and null respectively. In B, the same records have different values for the two columns. Table A needs to updated with these values currently in B. I have the following the query that I am hesitant to use since the explain shows a very high cost and a full table scan of B.
update A a
set (status,my_status) = (select b.status, b.my_status from B b, A a where a.id = b.id)
where a.date >= '01-JAN-2003' and a.cd = 'FD'.
As the above query shows, the where condition in the outer part(where a.date >= '01-JAN-2003' and a.cd = 'FD'.) ensures that only those records present in B are updated in A. Is there any way to join at the outer part where I can just specify A.id = B.id rather than having two conditions? Or is there any other route that would optimize this sort of a query?

Hi,
Be sure to put unique constraints on A.ID and B.ID like so before running the UPDATE view statement, like this:
ALTER TABLE a ADD CONSTRAINT a_uk1 UNIQUE (id);
ALTER TABLE b ADD CONSTRAINT b_uk1 UNIQUE (id);Then, remember to gather stats like so:
BEGIN
   FOR x IN (SELECT table_name
             FROM user_tables
             WHERE table_name IN ('A', 'B')) LOOP
     DBMS_STATS.gather_table_stats (ownname               => USER
                                  , tabname               => x.table_name
                                  , partname              => NULL
                                  , estimate_percent      => DBMS_STATS.auto_sample_size
                                  , block_sample          => FALSE
                                  , method_opt            => 'FOR ALL INDEXED COLUMNS SIZE 254'
                                  , degree                => NULL
                                  , granularity           => 'ALL'
                                  , cascade               => TRUE
                                  , no_invalidate         => FALSE
   END LOOP;
END;
/Good luck!

Similar Messages

  • Optimize the following update on per_all_assignments_F

    Hi
    I am trying to optimize this sql which is taking a long time to complete.
    declare
    cursor c1 is
    select person_id, annual_rt from xxdl.xxdl_papf_scrambling_view;
    begin
    for i in c1
    loop
    update PER_ALL_ASSIGNMENTS_F
    set as_attribute4 = i.annual_rt
    where person_id = i.person_id
    end loop;
    end;
    There are indexes on ass_attribute4, i.annual_rt, person_id, i.person_id.
    per_all_assignments_f is a standard oracle apps table.
    xxdl.xxdl_papf_scrambling_View is a custom table that I created by joining some columns in per_all_people_f and some other views and tables in peoplesoft database. Basically the objective is to scramble the data in oracle based on already scrambled data in peoplesoft. So I create xxdl_papf_scrambling_view using info from psft database (over a db link) and then try to use the information in the custom table to update the ebusiness tables on oracle financials. The updates appears to be working except that some of them like the one above are slow.
    I tried using a corelated update (but it does not work because single row subquery returns more than one row and I was not sure how to join these tables to make it return one row based on how I created the above tables)
    and I used bulk collect and forall but the performance is not any better.
    Any ideas or suggestions.
    Thank you
    Kumar
    Edited by: Kumar Madduri on Nov 2, 2009 6:55 AM

    Hi
    I tried that approach already but the subquery returns more than one row.
    ERROR at line 2:
    ORA-01427: single-row subquery returns more than one row
    and this one runs in roughly one hour which I am trying to further reduce
    declare
    cursor c1 is
    select person_id, annual_rt from xxdl.xxdl_papf_scrambling_view;
    type pid_tab is table of xxdl.xxdl_papf_scrambling_view.person_id%type;
    type art_tab is table of xxdl.xxdl_papf_scrambling_view.annual_rt%type;
    pid_tab1 pid_tab;
    art_tab1 art_tab;
    begin
    open c1;
    loop
    fetch c1 bulk collect into pid_tab1, art_tab1;
    forall i in 1..pid_tab1.count
    update PER_ALL_ASSIGNMENTS_F
    set ass_attribute4 = art_tab1(i)
    where person_id = pid_tab1(i);
    exit when c1%notfound;
    end loop;
    close c1;
    end;
    Edited by: Kumar Madduri on Nov 2, 2009 7:09 AM

  • I have an epson T50 shared network, which is connected to a computer that runs on Windows 7 64-bit. The 10 days Apple has updated the printer drive and since then has been trying to print the following message: / Library/Printers/EPSON/InkjetPrinter2/Filt

    I have an epson T50 shared network, which is connected to a computer that runs on Windows 7 64-bit. The 10 days Apple has updated the printer drive and since then has been trying to print the following message: / Library/Printers/EPSON/InkjetPrinter2/Filter/rastertoescpII.app/Contents/MacOS/ rastertoescpII failed.
    What should I do?

    The first thing you should do is re-write your post to make it a bit more understandable. I got you have an Epson printer connected to your PC, however after that  your post doesn't make any sense. Are you attempting to print from your iMac, if so then you need to download and install Bonjour for Windows on your Windows machine. Then set Windows so it has printer sharing turned on and then on the iMac simply follow Apple's instructions for adding a printer.
    http://support.apple.com/kb/DL999
    http://support.apple.com/kb/HT4670

  • Installation Failure: Windows failed to install the following update with error 0x800F0922

    Hi folks,
    I have a HP Elitebook Folio 9470p.  It came with Windows 8, and I installed it on my corporate domain.  I was trying to do some Windows updates so  I could upgrade it to Windows 8.1, but it fails installing the updates, whether or not I try
    to install them one at a time or all of them.  It has about 18 updates it needs from security updates to a .net framework update.  I run Symantec EP, and disabled it, checked for driver updates for things like display and networking and they are
    all up to date.
    I'm at a loss as to what to do.  It gives this error in the event log for each file, Event ID 20.
    Installation Failure: Windows failed to install the following update with error 0x800F0922: Security Update for Windows 8 for x64-based Systems (KB2862152).
    This is the example for KB2862152, but it gives the same error for every one.  I've tried to auto fix for Windows update issues and it fixed a couple of the issues, but not all of them, and provides no other help.
    I also deleted folders and files from the SoftwareDistribution folder as well, to no avail.  Any ideas what I can do to get whatever updates it needs, so I can fully patch it, and upgrade it to Win 8.1?
    Thanks for any help!

    Hi MM. Mr Kywildcat and Vegan Fan,
    GOOD NEW ! At this time, my issue is solved. The only black side is "how ?" : I hope that we will get a response some day ; however, and for in information  pnly - hoping this could help someone - I resume some actions which allowed this the happy end
    1) about installing 8.1 : I wanted to be sure that gain/pain ratio was positive, and that upgrading from a (potentially) damaged system would'nt produce something looking like a new Win 8.1, but difficult to maintain and keeping some negative potentialities.
    2) I was influenced by the fact that this
    0x800F0922  error acted as "a serial killerror", whose root cause could be a unique update error at reboot time concerning several (>20) packages, so I decided to test some manual upgrades.
    3)   Manual update (i.e. manual download and maunching of .msu packages) of the 2 following packages
    (whose update previously failed on a Windows Update) was successful : .NET Framework version 3.5 for  x64 (KB2898866) and Camera Codec Pack Windows 8 for x64 (KB2899190)
    4) So I decided to try Windows Update on a selection of packages, first : those concerning .Net Framework 3.5 and 4.5 (that is: KB2898866, 2901120, 2898865) --> Successful !
    5) finally, I selected almost all other packages, with some exceptions wich I (think to) have no need for : KB2871690, 2904659, 2843630. To be complete, here is the list of pakages updated one time at all :
    KB 2892074, 2893294, 2893984, 2909210, 2912390, 2916036, 2889784,2903938, 2911101, 2913152, 2917499
    --> always succesful.
    I am not a specialist, but I uess that this 0x800F0922 error hides another problem which is globally "H-RESULTED"
    to all updates pending in one update operation with reboot. This could be assumed from this CBS.log exterped from my last wrong attempts, where root cause seems not to be
    0x800f0922, but 0x80004003 :
    2014-02-15 21:29:13, Info                  CBS    Could not get active session for current session file logging [HRESULT = 0x80004003 - E_POINTER]
    2014-02-15 21:29:13, Info                  CBS    Not able to add pending.xml.bad to Windows Error Report. [HRESULT = 0x80070002 - ERROR_FILE_NOT_FOUND]
    2014-02-15 21:29:18, Error  CBS    Startup: Failed to process advanced operation queue, startupPhase: 0.  A rollback transaction will be created. [HRESULT = 0x800f0922 - CBS_E_INSTALLERS_FAILED]
    Anyway, thanks to you who spent some of your time to describe issues and search/ suggest solutions ; I will upgrade my system to 8.1 anyway, some of this day, when I am sure that my configuration does not hides some other problem. I thing that potential
    issue remains until maybe a new KB corrects it, wrong :-) ?
    And I hope that you - Mr Kywildcat - can upgrade your system on "current levels" trying similar attempts. 
    Phil   

  • HT5654 I tried to install the new update to iTunes on my Windows XP computer and I keep getting an error that say iTunes was not installed properly. Please reinstall iTunes.  I tried that and it still won't work.  Got any ideas what is wrong?

    I tried to run the new update to iTunes and I got the error....iTunes was not installed properly.  Please reinstall iTunes.  I have tried that twice with no success.  Anyone have any ideas what the problem is?

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • HT5654 Trying to install the latest update for itunes...error received "service apple mobile device failed to start.  verify thay you have sufficient priveleges to start system services"...?  I have unistalled and tried to reinstall???

    Trying to install the latest update for itunes...error received "service apple mobile device failed to start.  verify thay you have sufficient priveleges to start system services"...?  I have uninstalled and tried to reinstall???

    Hello Kimberly0914,
    It sounds like you have tried to launch iTunes after a recent update due to this error message, and you cannot install iTunes after uninstalling. I recommend the troubleshooting from the following article to help you named:
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/ht1926
    Then download and install iTunes with this link:
    http://www.apple.com/itunes/download/
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • I am running Acrobat X Pro on Windows 7 in Parallels. I have tried to install the Acrobat updates, but they won't install. Today I tried to create a pdf from a Word 2013 document and it crapped out. I tried to uninstall Acrobat and got Error 1310. Error w

    I am running Acrobat X Pro on Windows 7 in Parallels. I have tried to install the Acrobat updates, but they won't install. Today I tried to create a pdf from a Word 2013 document and it crapped out. I tried to uninstall Acrobat and got Error 1310. Error writing to file: c:\Config.Msi\feea.rbf. What do I do?

    Hi Beverly ,
    Please refer to the following and see if this helps.
    https://helpx.adobe.com/creative-suite/kb/error-1310-error-writing-file.html
    Regards
    Sukrit Dhingra

  • Windows failed to install the following update with error 0x80070005

    Hi,
    We are using Win Server 2008 R2 std. Server and Win 7 Professional X64 clients. During the second batch of update we got an Error while updating on one client machine and the system restoring back automatically However other clients are updating and working
    fine. Then i tried to install the updates one by one manually then successfully installed all the updates except one ie. KB2862330. It keeps failing then i found an article suggest to check the update with Admin Previlage, disable Antivirus and Scan the
    computer for Malware (Using MS Security Scanner and Malwarebytes). I tried both but never works. After that i got 2 batch of updates, everything is updating and trying to update this (KB2862330) and failing till date. What is the issue and why its not updating
    on one machine?
    Installation Failure: Windows failed to install the following update with error 0x80070005: Security Update for Windows 7 for x64-based Systems (KB2862330).
    KB Article Followed : http://support.microsoft.com/kb/968003/en-us

    Okay, good. The SURT shows no errors.
    So now we can blame the problem exclusively on the update itself.
    And yes... there are still known, ongoing issues with KB2862330.
    Truly, my suggestion is to just not install it at all. Unless you've identified a known risk via a USB vector on particular systems where the vulnerability would be considered a critical risk, I'd say that the risk caused by the vulnerability is significantly
    less than the risk of additional headache caused by the update itself. I have still not deployed MS13-081 to any of my systems, and frankly, I don't plan to.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • I got the MSCVR80.ddl message after I tried to do the latest update on Itunes.  I went in and deleted all the related programs and reinstalled, but I keep getting a message during installation that "Service 'Apple Mobile Device' failed to start. Help!

    I was trying to do the latest update on my desktop for my Itunes.  I got MSVCR80.dll is missing.  I saw a post about deleting all the apple itunes programs, restarting and reinstalling.  I tried that.  As it was installing a message came up about "Service'Apple Mobile Device' failed to start. Verify that you have sufficient privileges to start systems services.  I did a retry, got the same message, then hit ignore.  It went on.  Then a message popped up saying "Itunes not installed correctly"  Error 7 (Windows error 126)
    Now my Itunes program will not open at all.  What gives?  This is very frustrating and I am not very computer literate to begin with.

    Hi Iss9243,
    Welcome to the Support Communities!
    You've already tried some great troubleshooting steps, but the article below gives you quite a few more for this issue.  Hope it helps ....
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Cheers,
    - Judy

  • Heey i bought an iphone 3gs about 2-3 months ago (used) today i blanked off the phone itself and then tried to get the newest update cuz i wasnt able to before so i did and now im locked out and it says sim failure invalid sim i can even get into it :(

    heey i bought an iphone 3gs about 2-3 months ago (used) was in mint condition well taken care of not even a scratch as soon as i got home i tried syncing it to my computer but didnt work it didnt even sync or notice my iphone software .. so i went to my friends and synced it there it has been working for music but videos wont work? but i didnt care  and then the pop up that says update so we would click it wait and it wouldnt work ever since ive had it so i left it like that so i went to my friend today i blanked it off the phone itself and then tried to get the newest update cuz i wasnt able to before so i did and now im locked out and it says sim failure invalid sim i can even get into it PLEASE HELP and cant get a new sim at the moment or take it into the apple store because i live about an hour and a half away from the city and rarley go to it please help me !!!!!!!!!!!!!!

    When I use find file http://www.macupdate.com/app/mac/30073/find-file (which does tend to find files that "Finder" can't), it's not coming up with any other itunes library files that have been modified in the past week, which I know it would have been - unfortunately, I don't have a very recent backup of the hard drive.  It would be a few months old so it wouldn't have the complete library on it....any ideas?  I'm wondering if restarting the computer might help but have been afraid to do so in case it would make it harder to recover anything...I was looking at this thread https://discussions.apple.com/thread/4211589?start=0&tstart=0 in the hopes that it might have a helpful suggestion but it's definitely a different scenario.

  • I am using Acrobat XI Pro and tried to install the current update. I got this error message: "Error 1328.Error applying patch to file C:\Config.Msi\pT64b3.tmp It has probably been updated by other means1 and can no longer be modified by this patch. For mo

    I am using Acrobat XI Pro and tried to install the current update. I got this error message: "Error 1328.Error applying patch to file C:\Config.Msi\pT64b3.tmp It has probably been updated by other means1 and can no longer be modified by this patch. For more information contact your patch vendor." tried uninstalling and reinstalling and still get the error. Searched for C:\Config.Msi\pT64b3.tmp and cannot find the path or the file

    For AA XI, you only need the 11.0.09 patch. Download from http://www.adobe.com/support/downloads/product.jsp?product=1&platform=Windows (Use "MAC" if a MAC is used).

  • Failed to Install The New Preview Build. Installation Failure: Windows failed to install the following update with error 0x80246007: FBL_AWESOME1501 9926 Professional.

    Hello,
    I'm having issues upgrading my Windows 10 Technical Preview installation build 9879 to a newer build that's become available late January 23rd.
    I am installing the new upgrade in a Hyper-V virtual machine and get the following error:
    Failed to install the new preview build, please try again later. 0x80246007
    What could be the problem?
    Previously I've had messages that Windows cannot be upgraded on a computer with less than 2 Gbyte of RAM. That's a Hyper-V VM with dynamic memory and I was highly surprised to see this error; never had this before. Had to set 2048 Mbytes as a minimum memory
    for this VM. Now that I have this 80246007 error code.
    When looking up System log, the following error messages are listed multiple times:
    Installation Failure: Windows failed to install the following update with error 0x80246007: FBL_AWESOME1501 9926 Professional.
    The errors are returned for the Event ID 20 by WindowsUpdateClient
    in task category Windows Update Agent..
    I reviewed the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsSelfHost\Applicability
    registry key as suggested in Windows
    Insider stuck on build 9841 - "No new preview build was found", and here is what it shows:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsSelfHost\Applicability]
    "BranchName"="fbl_awesome1501"
    "ThresholdRiskLevel"="low"
    "ThresholdOptedin"=dword:00000001
    Note, when attempting to install the downloaded update from a native boot, installation starts with no errors.
    However, since setup is not supported for a natively booted VHD files, it does not proceed further showing a message that installation on virtual drives is not supported.  
    Looks like Setup is having problems installing in a Hyper-V virtual machine.
    Possibly, some ESD files got corrupted during downloading? Is it possible to remove them and re-download missing files? (I, however, noticed that Windows seems to re-download upgrade files after you restart 9879 and attempt to check for a new build.
    Any clue why installing under VM causes 9926 to fail?
    Thank you in advance.
    Well this is the world we live in And these are the hands we're given...

    Hi,
    According to the error message, this problem seems like update package installation failed during system upgrade.
    You can try to remove ESD file which locate at boot of C drive and upgrade the system again for test.
    On the other hand, make sure the system 9879 installed all Windows pushed updates before system upgrade.
    Roger Lu
    TechNet Community Support

  • Have reformatted my Imac using original discs (installed leopard (10.5)) tried to do the software update but it cant download the itunes update and when it gets to the configure update screen after restart for main update, it just gets stuck. HELP!

    have reformatted my Imac using original discs (installed leopard (10.5)) tried to do the software update but it cant download the itunes update and when it gets to the configure update screen after restart for main update, it just gets stuck. HELP!
    The configure bar gets about an 1/8 full and then just does nothing. I think its lists the update as combo update? cant remember with out checking.
    I have tried to do the disk verify and repair but this has made no difference.
    Please let me know what i need to do, I have reformatted the mac just to start over as was clogged with a lot of useless data, I had installed lion (10.7) from the app store previously and now cant seem to find a way to re install lion. I hope I dont need to pay for it again?

    If you erased your hard drive, you'll need to reinstll OS X 10.6 Snow Leopard to access the App store. You won't have to pay for OS X 10.7 Lion again. Did you try booting to the recovery partition by holding the command and r keys down? If that's still there, you can reinstall OS X 10.7 from there.
    If you're looking to install the current iTunes, you need OS X 10.6.8 at a minimum.
    If you're still trying to update OS X 10.5 Leopard, you can download the combo update from here.  Download, use Disk Utility to repair permissions, apply the update, then repair permissions again. That will take you to OS X 10.5.8.

  • Trying to install the new update and it kept saying runtime error and now my itunes has dissapeared from my computer.  All my music is gone!How do i get it back?

    trying to do the new update. it said runtime error``     and now my itunes is empty on my computer,  where/how do I get my music and playlists back?

    See Empty/corrupt library after upgrade/crash.
    tt2

  • I keep getting an error when trying to receive the new update iOS7 on iPhone5.  Any suggestions?

    I keep getting an error when trying to receive the new update iOS7 on iPhone5.  Any suggestions?

    Do the update using iTunes on your computer.
    Plug your iPhone into iTunes (current version), let it sync, then click "Check for Updates" on the iPhone's summary page in iTunes.

Maybe you are looking for