Select/Update taking far too long to run, how can I get it to go faster?

Hello all,
I am trying to do an update/select on a table that returns 16 million records. So far most of the time it takes forever to complete or never finishes. Initially I was trying to do it as one big select, but when that didnt work, i broke it down to creating a table with the "base" 16 million records, and am trying to fetch additional values for each of those records from the table i grabbed those records from. Doing a select got me no where, so I am trying to do an update of the tables with the values i find using a cursor. Even this does not seem to be working. Is there a way to do it with a batch/bulk update that would be faster? The code is as follows: (oracle 10g):
DECLARE 
   CURSOR wr63993_cur IS
      SELECT   provider_id,
               din_gp_pin,
               orig_prescription_nbr,
               adjudication_date
        FROM   WR63993_BASE
       WHERE   adjudication_date BETWEEN to_date('2009/07/01', 'yyyy/mm/dd') AND to_date('2009/07/31', 'yyyy/mm/dd');
   CURSOR date_cur (v_provider_id WR63993_BASE.provider_id%TYPE,
                    v_din_gp_pin WR63993_BASE.din_gp_pin%TYPE,
                    v_orig_prescription_nbr WR63993_BASE.orig_prescription_nbr%TYPE,
                    v_adjudication_date WR63993_BASE.adjudication_date%TYPE)
      IS
      SELECT   MIN(adjudication_date) min_date
        FROM   claim_history@posi
       WHERE   provider_id = v_provider_id
         AND   din_gp_pin = v_din_gp_pin
         AND   orig_prescription_nbr = v_orig_prescription_nbr
         AND   adjudication_date >= ADD_MONTHS(v_adjudication_date, - 24);
BEGIN
   FOR wr63993_rec IN wr63993_cur LOOP
      FOR date_rec in date_cur(wr63993_rec.provider_id, wr63993_rec.din_gp_pin, wr63993_rec.orig_prescription_nbr, wr63993_rec.adjudication_date) LOOP
         UPDATE   WR63993_BASE
            SET   min_date = date_rec.min_date
          WHERE   provider_id = wr63993_rec.provider_id
            AND   din_gp_pin = wr63993_rec.din_gp_pin
            AND   orig_prescription_nbr = wr63993_rec.orig_prescription_nbr;
      END LOOP;
  END LOOP;
  COMMIT;
END;
/

aaah. healthcare insurance :)
The performance of these, as i'm sure you know, is tricky.
Consider the following which could help you eliminate your cursors. Here, B.adjudication_date will be the same as "MIN(adjudication_date) min_date" from your query.
I understand that this is typically outside of your control, but if it is at all possible, move all of the data to the same database so you don't need those distributed queries. Separate schemas is ok.
Select
  stuff
From Wr63993_Base A
Inner Join Claim_History@Posi B On A.Provider_Id=B.Provider_Id And A.Din_Gp_Pin=B.Din_Gp_Pin And A.Orig_Nbr=B.Orig_Nbr
--the next table will allow you to get *earlier* instances of the claim where the adjudication date was in past 24 months
--we only want to see the row where there ARE NO EARLIER instances. So this LOJ will return null for that row.
Left Outer Join Claim_History@Posi C On A.Provider_Id=C.Provider_Id And A.Din_Gp_Pin=C.Din_Gp_Pin And A.Orig_Nbr=C.Orig_Nbr
and c.adjudication_date >= ADD_MONTHS(a.adjudication_date, - 24) and c.adjudication_date<b.adjudication_date
Where  
  A.Adjudication_Date Between To_Date('2009/07/01', 'yyyy/mm/dd')
  And To_Date('2009/07/31', 'yyyy/mm/dd')
  And B.Adjudication_Date >= Add_Months(A.Adjudication_Date, - 24)
  and c.adjudication_date is null --only get the row where B is the earliest qualifying adjudication date.
Dave

Similar Messages

  • I have myyahoo set as my search engine. When I try to open this page I get an message saying that it cannot be opened because of too may redirects.  How can I get this to open again?

    I have myyahoo set as my search engine.  Every time I try to open it a get a message that myyahoo cannot be opened because of too many redirects.  How can I get myyahoo page to open?

    Once you have obtained an external drive and connected it you will 'clone' your internal drive to it.
    Download Carbon Copy Cloner (it is not free but there is a fully functional trial version which is). Use it to clone your internal drive to your external drive. When that is done you will reboot from the clone and use Disk Utility to erase the internal drive (choose Mac OS Extended (Journaled)) as the format (this is normally preset, but check). Make sure to give the external drive a 'distinctive' name, don't want to get drives mixed up in this process.
    Once that is done you will use Carbon Copy Cloner (from the clone) to restore the external to the internal.

  • Update statement takes too long to run

    Hello,
    I am running this simple update statement, but it takes too long to run. It was running for 16 hours and then I cancelled it. It was not even finished. The destination table that I am updating has 2.6 million records, but I am only updating 206K records. If add ROWNUM <20 to the update statement works just fine and updates the right column with the right information. Do you have any ideas what could be wrong in my update statement? I am also using a DB link since CAP.ESS_LOOKUP table resides in different db from the destination table. We are running 11g Oracle Db.
    UPDATE DEV_OCS.DOCMETA IPM
    SET IPM.XIPM_APP_2_17 = (SELECT DISTINCT LKP.DOC_STATUS
    FROM [email protected] LKP
    WHERE LKP.DOC_NUM = IPM.XIPM_APP_2_1 AND
    IPM.XIPMSYS_APP_ID = 2
    WHERE
    IPM.XIPMSYS_APP_ID = 2;
    Thanks,
    Ilya

    matthew_morris wrote:
    In the first SQL, the SELECT against the remote table was a correlated subquery. the 'WHERE LKP.DOC_NUM = IPM.XIPM_APP_2_1 AND IPM.XIPMSYS_APP_ID = 2" means that the subquery had to run once for each row of DEV_OCS.DOCMETA being evaluated. This might have meant thousands of iterations, meaning a great deal of network traffic (not to mention each performing a DISTINCT operation). Queries where the data is split between two or more databases are much more expensive than queries using only tables in a single database.Sorry to disappoint you again, but with clause by itself doesn't prevent from "subquery had to run once for each row of DEV_OCS.DOCMETA being evaluated". For example:
    {code}
    SQL> set linesize 132
    SQL> explain plan for
    2 update emp e
    3 set deptno = (select t.deptno from dept@sol10 t where e.deptno = t.deptno)
    4 /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3247731149
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
    | 0 | UPDATE STATEMENT | | 14 | 42 | 17 (83)| 00:00:01 | | |
    | 1 | UPDATE | EMP | | | | | | |
    | 2 | TABLE ACCESS FULL| EMP | 14 | 42 | 3 (0)| 00:00:01 | | |
    | 3 | REMOTE | DEPT | 1 | 13 | 0 (0)| 00:00:01 | SOL10 | R->S |
    PLAN_TABLE_OUTPUT
    Remote SQL Information (identified by operation id):
    3 - SELECT "DEPTNO" FROM "DEPT" "T" WHERE "DEPTNO"=:1 (accessing 'SOL10' )
    16 rows selected.
    SQL> explain plan for
    2 update emp e
    3 set deptno = (with t as (select * from dept@sol10) select t.deptno from t where e.deptno = t.deptno)
    4 /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3247731149
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
    | 0 | UPDATE STATEMENT | | 14 | 42 | 17 (83)| 00:00:01 | | |
    | 1 | UPDATE | EMP | | | | | | |
    | 2 | TABLE ACCESS FULL| EMP | 14 | 42 | 3 (0)| 00:00:01 | | |
    | 3 | REMOTE | DEPT | 1 | 13 | 0 (0)| 00:00:01 | SOL10 | R->S |
    PLAN_TABLE_OUTPUT
    Remote SQL Information (identified by operation id):
    3 - SELECT "DEPTNO" FROM "DEPT" "DEPT" WHERE "DEPTNO"=:1 (accessing 'SOL10' )
    16 rows selected.
    SQL>
    {code}
    As you can see, WITH clause by itself guaranties nothing. We must force optimizer to materialize it:
    {code}
    SQL> explain plan for
    2 update emp e
    3 set deptno = (with t as (select /*+ materialize */ * from dept@sol10) select t.deptno from t where e.deptno = t.deptno
    4 /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3568118945
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
    | 0 | UPDATE STATEMENT | | 14 | 42 | 87 (17)| 00:00:02 | | |
    | 1 | UPDATE | EMP | | | | | | |
    | 2 | TABLE ACCESS FULL | EMP | 14 | 42 | 3 (0)| 00:00:01 | | |
    | 3 | TEMP TABLE TRANSFORMATION | | | | | | | |
    | 4 | LOAD AS SELECT | SYS_TEMP_0FD9D6603_1CEEEBC | | | | | | |
    | 5 | REMOTE | DEPT | 4 | 80 | 3 (0)| 00:00:01 | SOL10 | R->S |
    PLAN_TABLE_OUTPUT
    |* 6 | VIEW | | 4 | 52 | 2 (0)| 00:00:01 | | |
    | 7 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6603_1CEEEBC | 4 | 80 | 2 (0)| 00:00:01 | | |
    Predicate Information (identified by operation id):
    6 - filter("T"."DEPTNO"=:B1)
    Remote SQL Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    5 - SELECT "DEPTNO","DNAME","LOC" FROM "DEPT" "DEPT" (accessing 'SOL10' )
    25 rows selected.
    SQL>
    {code}
    I do know hint materialize is not documented, but I don't know any other way besides splitting statement in two to materialize it.
    SY.

  • Compressor 3 taking far too long to compress H.264

    Origianally posted this here:
    http://discussions.apple.com/thread.jspa?messageID=7328851&#7328851
    But thought I would start a new topic.
    Something is very wrong. I sent a 9 minute MPEG-2 file to Compressor to have compressed to H.264. (H.264 compression is what I would gather many of us are using Comp for in the first place).
    I know Compressor can do H.264 comp at about 1.43:1 from tests. So a 9 minute clip should take, 6 minutes or so, and with Q Master it should be even faster. Well, Comp reports 8-9 hours. What the heck is going on.
    I have taken MPEG Stream Clip and done the same H.264 output and it takes about 6-7 minutes. Something is up with Comp 3.
    Now I have turned off Q Master, Reset the Comp 3 BG Processing, Quit Comp and relaunch, maybe reboot, possibly trash all prefs related to Comp.
    And still 8-9 hours?
    A 9 minute clip should take 6 minutes and as I say, with Q Master, even faster, that is the point of Q Q Master services
    Message was edited by: macguitarman

    Took me awhile to get Compressor going reliably but now it has been pretty solid.
    I am not sure what settings you are using to encode (for instance Frame Controls can add alot of time), but 8-9 hours for 9 Minutes seems rather extreme. Note though that you are using an MPEG-2 (m2v?) file. You may be better off converting to another Codec or better yet go to the source material you are double encoding.
    I just set up a Compressor setting on an Octo 2.8 with everything pushed to the Max on Frame Controls and set to resize a 6 Minute HD AIC stream down to H.264 @25% of the size of the original and sent out to "This Computer" and not the Cluster and it took 17 minutes or so. Even with converting from m2v it does seem like it is taking way too long on the machine for you.
    I saw you had done some troubleshooting, but do you have any other details? Was his a clean install of the OS and Studio, or were there upgrades along the way? That caused some issues in the past - meaning between upgrades to Leopard and/or installing Studio 2 over Studio 1.

  • I Have an older IPod Mini that was synced to a computer I no longer have. How can I get the song on it to a new Library without losing the songs

    I have an older IPod Mini that was synced to a computer I no longer have. How can I move the songs on it to a newer library without losing the songs?

    iOS: Unable to update or restore

  • IPhoto update from Mavericks deleted my library. How can I get my pictures back?

    Soo my iPhoto just decided not to find my photo library anymore.
    When I open iPhoto, it only opens a windwo where I can decide which library I want to open, but gives me no choices, the list is empty. Normally this window opens when my external HD is connected to my macbook since then there's two iPhotos available, but now it just doesnt find even one.
    I had another problem with the iPhoto on my external HD, i wanted to open it but a window opened to tell me that my library is used by another programm or that the library can't be read anymore. I was able to save those pictures by showing the contents and copying the pictures.
    Buuuut now on the macbook, when I do the left click thing to open the contents of the package, there are no pictures in it at all, no folder has pictures in it. When I copy the version from time machine, nothing changes. iPhoto has a size of 1.7 Gb, which is way to small. God dammit.
    How can I get my pictures back?

    Thank you Terence!
    Okay, so here the details:
    iPhoto Version 9.5.1
    OS X Version 10.9.1
    So here what I did, detailed. (pardon my english, I'm swiss)
    I downloaded Mavericks, few days later updated iPhoto (the iPhoto icon was orange before and turned blue after the update). All went well, until one month later, all of a sudden, I was not able to open my iPhoto on the external harddisk. A window opened to tell me that either my library is being used by another programm or that it can't be read anymore. To solve this problem iPhoto tells me to do several things, for example shut down the computer and then open iPhoto again, or set up my library again or open iPhoto by pressing command and alt. But non of those instructions helped. So I opened the contents, I looked for the folder with the masters of my pictures and copied the whole thing onto another harddisk.  
    I think I got those Pics saved, but I still can't open iPhoto on the external harddisk.
    Oh and by the way, the iPhoto icon on my external harddisk looks different now, it's three pictures in a row and the one on top shows a redish flower.
    So now, two days later I try to open the iPhoto on my regular macbook. A window pops up and says that I have to choose a library that I want to open. (iPhoto usually did that when I had my external harddisk connected since there were two different librarys then, one on my external, one on my computer) But now, instead of showing me the library's I can choose from it only shows nothing, no list or anything i could even choose. And then below there's this button that says something like "create a new library".
    So what I did:
    I open the contents and looked for the masters of my pictures, but there weren't any pictures at all. The iPhoto has a size of 1.7 GB which I think is too small for all the Pics and videos i stored in there.
    I tried to get the IPhoto from Time Machine, but nothing changed. Iphoto still's 1.7 GB.
    I opened the file "Pictures" in the Finder, but there's no such file like "iPhoto library", like it's deleted or something like that.
    So i think that I used iPhoto usually, nothing speciall. I imported Pictures from my iPhone or camera and left them there.
    Does that help?

  • HT4623 My iphone has 7.85gb of "other" space and won't let me update because of lack of space. How can I get rid of this "other" space?

    I am trying to update my wifes 4s to iOS 7 but her "other" has so much space taken up that it will not update. How can i get rid of "other" data space?

    tgarmy wrote:
    Now it tell me Itunes cannot backup because an "error" occured???? If i can't back it up then what do i do?
    Restart the computer and the iPhone might resolve a backup issue. Also, try resetting the iPhone by holding both the sleep/wake button and the Home button at the same time for at least 10 seconds until the Apple logo reappears. Afterward, attempt to restore again.
    Before you restore,  consider a few other things... One particular onging thread regarding "other" data has users finding that text messages with photos and/or videos taking up the "other" space. Deleting those text conversations helps regain space. (Before deleting, transfer any photos and videos you want to keep to your camera roll or computer.) In addition, check for any deleted phone voicemail messages and delete those to as well as voice memos.
    If you decide to restore, the recommendation is to restore as new phone because the backup probably has the "other" data.
    HTH

  • I purchased music using a APPLE ID that was a old companies email address.  I have a new iPod Classic and I startign to set it up and I can't remember the password to my old account and the email for verification no longer exists.  How can I get the old ?

    I Purchased a bunch of music under an old ID and email.  I no longer have the email and I can't remember the password.  How can I get the music I bought unlocked so it will be loaded on my new iPod classic??

    ➡ https://iforgot.apple.com/

  • I updated my iphone and everything disappeared. How can I get that back?

    I upated my iphone 3g today and when the update was finished all my contacts, photos, txt messages, and everything was gone. How can I get all that back, or atleast my contacts? Please someone help!

    You should be syncing your contacts/calendars to your computer regularly ( Outlook for example).
    Sync them back.
    http://manuals.info.apple.com/enUS/iPhone_iOS4_UserGuide.pdf
    EVERYTHING on your iphone should always be on your computer as well and included in your regular backup copy of your computer.

  • I need proof of purchase for obtaining a replacement item purchased from the i-tunes store. The e-mail is no longer available. How can I get this?

    I need prrof of purchase to obtain a replacement item purchased in i-tunes. How can I get this? The e-mail does not appear to be available any longer.

    Check your iTune Purchase History.
    http://support.apple.com/kb/ht2727

  • HT4623 when I updated my iphone I lost my photos, how can I get them back?

    When I updated my iphone, and I lost all my photos, how can I get the back?

    sync your pictures back using itunes, you do import your pics to your PC right? http://support.apple.com/kb/HT4083
    or restore from backup http://support.apple.com/kb/HT1766

  • I selected manually manage music for my iTouch yet it keeps trying to sync to my entire music library.  I do not want that as it is taking up too much space.  How can I stop my iTouch from continuing to try and sync so I can manually manage my music?

    How do I get my iTouch to manually manage my music?  I selected manually manage, yet every time I hook my iTouch to my computer, it attempts to sync and load my entire library.  I do not want the entire library as it takes up too much space and I don't want all of those songs on my iTouch.  What am I missing?  What else can I do? 

    Oops, sorry, I think you probably already did what I suggested (turning off auto synch).
    I have the same question - how to synch, say, just one playlist.
    There is an option to synch only things that are checked. But everything (in every playlist and item, is checked and there doesn't appear to be a box to "uncheck all", nor can you check each playlist individually.

  • Itunes asked me to do an update- I did- it will no longer load. How can I get the itunes program to work?

    Itunes has onced worked on my computer with previous settings. I was asked by Itunes to make a necessary update, which I did. Now Itunes will not work on my computer.

    atoo2 wrote:
    I just did the IOS8 update on my Ipad retina which had 300  photos it asked me to do an iCloud back up which i did but it deleted all my previous photos and now i only have recent photos how do i get back all my old photos? It said befor that my icloud was out of storage but i didnt know it didnt have my old photos, they arnt back up on itunes either is there any way I can get them back?
    Please see the bold.  If you're out of icloud storage, then you won't be able to backup to icloud unless you purchase more storage, but yet you said you backup to icloud.
    If you really did backup to icloud no data would be loss - sounds to me that it didn't backup since you had no more free icloud storage space.
    iCloud: iCloud storage and backup overview

  • I purchased and downloaded a full album on itunes today, when i got home i updated my phone and lost it all, how can i get this music back without paying for it again

    Today while driving home from vacation i purchased and downloaded the new Nichleback CD, when i got home, i plugged my phone into my computer to update everything and it pulled up a message saying something like "this computer has recognized an iPhone that is in memory update, you will need to restore the phone" or something similar to that, it had a picture of the power cord plugging into iTunes on the screen and i couldn't get rid of it, so i had to plug it in and restore everything, when it was done i noticed that not only did i loose the new CD that i had just purchased today but i lost all of the music that i've purchased since the last update. How can i restore this music without purchasing it all again?

    Media should be included with the backup of the computer that all users should be creating on a regular basis as part of basic computer/data maintenance.
    In the event that you do not have a backup (stop being lazy.... keep backups of YOUR data and other important files)
    If you are in the US and running iTunes 10.3 or later, it is possible to redownload music via iCloud from purchased history.
    If you are not in the US or for some reason cannot run iTunes 10.3 or later, contact iTunes customer support and ask very nicely for the opportunity to redownload the content.  They are not required to provide this opportunity.
    It is also possible to transfer content from an iDevice that was purchased via iTunes.  On the new computer, sign into the iTunes account, authorize the computer, connect the device then select File > Transfer Purchases.
    The simplest method of all is to transfer or copy the media (and other important files) from the old computer or the backup of the old computer.  Typing "move itunes library" into the search bar here or into google will reveal step by step instructions on how to do this.

  • Missing mscrv80.dll file when updating itunes.  what is it and how can I get it back?

    When updating itunes the new installation said I was missing mscrv80.dll file.  I've reinstalled but still doesn't work.  How can it be repaired?

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (if this won't uninstall move on to the next item)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
    Please note:
    Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
    HT1925: Removing and Reinstalling iTunes for Windows XP
    HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    tt2

Maybe you are looking for

  • F150 - Dunning layout

    Hi, can we assign the dunning layout to the user in the parameter Id . i want to assign the users different layout. is it possible in FB00. I run the F150 successfully and click on the dunning list. one of the  user wants to see the layout 0 and the

  • How do I install Windows Vista in my R500 that I just put a new hard drive into?

    I was given an R500 that had the hard drive removed by the previous owner for security reasons. I bought a charger and a new hard drive and intended to install Windows Vista that I bought a while ago and never used. I charged up the battery. The batt

  • Nokia n9 automatic lock

    Hi, if there is any one who can help me solve the problem with my Nokia N9 I will very grateful. My phone got automatically lock and when I looked up on the discussions apparently if I put in my Nokia account password it will unlock but the problemit

  • Using Current iTunes Library With New Nano

    My daughter's iPod Mini seems to have played it's last song and a new 2G Nano is on it's way. Is there anything that I need to do that may not be printed in the manual to transfer her current iTunes library on our PC to the new Nano? We run Windows X

  • Removing Currency Sign from report figures

    Hi, Please any one has an idea on how I can prevent the currency sign from appearing on the body of the workbook. I have column headers with the appropriate currency sign but I do not wish to see the key figure values appearing with the currency sign