How to tune update using subquery

T1 has 4 million records
T2 has 9 million records
Average number of records updated in T1 = 115,000
I am trying update table T1 (4 million records), with matching t_id from table T2 (9 million records), every night.
I tried the 3 version of the update, each of it taking around 30 minutes to update T1.
If I run the same sql immediately it completes within 5 minutes (execution plans are the same for both runs).
Could any one please explain what makes it run faster the second time? Any suggestions for performing this
update in a better way would be greatly appreciated...
create table T1
id varchar2 (18) not null,
t_date date not null,
t_id varchar2 (18),
processed varchar2 (1) default 'N',
constraint T1_pk primary key ( id, t_date )
create index T1_prcsd on T1(processed);
create table T2
id varchar2 (18) not null,
t_id varchar2 (18) not null
create unique index customer_idx01 on customer(custnum);
**1:**
update T1 a
set t_id = ( select b.t_id
from T2 b
where a.id = b.id)
where id in ( select id from T2)
and processed = 'N';
*2:*
update T1 a
set t_id = ( select b.t_id
from T2 b
where a.id = b.id)
where exists ( select 1 from T2 c where a.id = c.id)
and processed = 'N';
*3:*
update ( select /*+ USE_NL(T1) INDEX( T2 T2_idx01 ) */
                              a.t_id a_t_id
                              ,c.t_id c_t_id
               from T1 a, T2 c
               where a.id = c.id
               and a.processed = 'N'
set a_t_id = c_t_id;

Could any one please explain what makes it run faster the second time?Probably because data is cached if the second run is shortly after the first.
You already tried the correlated EXISTS I was going to suggest. How long do versions 1 and 2 take?
Are A.ID and A.PROCESSED both in one composite index?

Similar Messages

  • I have problems updating my app in the appstore. How should i update using itunes? Currently, i'm unable to use all of my apps.

    I have problems updating my apps in appstore for my IPad. How should i update it using itunes? I'm unable to see all the apps currently.

    Hallo. If all of your apps purchases from the same Apple ID, you can try to update them on iTunes, ways as below:
    iTunes 12 for Windows: Download previous purchases from the iTunes Store
    iTunes 12 for Mac: Download previous purchases from the iTunes Store
    Regards,
    Anson

  • How should I update using phone to 8.1.1

    please provide solution

    Hello TIMMANNA,
    I read your post, and it sounds as though you'd like to learn how to update your device. I have linked to an article that will instruct you on how to do that:
    Update the iOS software on your iPhone, iPad, and iPod touch - Apple Support
    iOS software updates introduce new features that let you do even more with your iPhone, iPad, or iPod touch. Be sure to keep your devices up to date so that you don't miss out on the latest features.
    Before you update
    Back up your device to iCloud or iTunes.
    If you use your device's Personal Hotspot for your computer's Internet connection, update your device wirelessly or connect your computer to another network.
    Update your device wirelessly
    The easiest way to update your device is wirelessly, also called “over the air.” Here’s how:
    Plug in your device to a power source.
    Tap Settings > General > Software Update.
    Tap Download and Install. Updates might download automatically while your device is connected to Wi-Fi and a power source.
    Tap Install, or tap Later to install the update later. If you use a passcode, you'll need to enter it before installing the update.
    If you have some free space, but not enough to update over the air, you can either update using iTunes or delete content manually from your device. Whether you use iTunes or update over the air, you'll have the same amount of free space on your device after you update.
    Some iOS software updates aren't available as over-the-air updates. VPN or proxy connections might prevent your device from contacting the iOS update servers.
    Update your device using iTunes
    If you can’t update wirelessly, or if you want to update with iTunes, follow these steps:
    Install the latest version of iTunes on your computer.
    Plug in your device to your computer.
    In iTunes, select your device.
    In the Summary pane, click Check for Update.
    Click Download and Update.
    If you don't have enough free space to update using iTunes, you'll need to delete content manually from your device.
    Find out what to do if you get other error messages while updating your device.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

  • How 'Assignment' is updated using VL02N transaction ?

    Hi Experts,
    I want to know how and where in the program SAPMV50A, the 'assignment' field is updated when  I post a GI document using VL02N transaction.
    The filed for assignment is ZUONR of BSEG table. I want to know how the ZUONR field is updated while VL02N transaction is used to post a GI document.
    Please help me asap.
    Thanks & regards
    Sanglap Ghosh
    Edited by: sanglap_ghosh581 on Mar 10, 2010 10:18 AM
    Edited by: sanglap_ghosh581 on Mar 10, 2010 10:20 AM

    Did you find a solution for this? I have the same requirement.

  • How to tune query using dblink?

    Hello,
    I have query running on production DB(Version 9i).
    The query is fetching data over the dblink.
    Its taking around 14 minutes and total number of rows fetched are around 2 million.
    Is there any way I can tune the query? I have used driving site hist but that didn't helped.

    Ario wrote:
    Hello,
    I have query running on production DB(Version 9i).
    The query is fetching data over the dblink.
    Its taking around 14 minutes and total number of rows fetched are around 2 million.
    Is there any way I can tune the query? I have used driving site hist but that didn't helped.
    Do some math and tell us if there is a way you can tune this.
    We have no idea what "2 million rows" means in terms of size. That could be 1GB of data, it could be 1PB of data. Figure out how much data you're trying to move (size wise), then figure out roughly how fast your network can pipe the data (again, we have no idea if you have a fiber line and this is an internal network between machines, or if you're transporting the data 1/2 way around the globe over a dial up connection).
    When you have all that figured out you'll know if the 14 minutes is / or is not an acceptable amount of time.
    Cheers,

  • HT4623 How can I update using the wifi for my iPad

    When I go to setting-general -then I don't see update software ,why

    You need to be on iOS5 or greater to update directly from the iPad.  If you're on iOS4, you need to update from iTunes on your computer.

  • How should I update using my phone to 8.1.1

    Please provide the appropriate answer, it's asking wifi connection but my iPhone wifi not yet turning on

    Thanks for telling us. Did you want help?

  • No of record updated using EXECUTE IMMEDIATE

    Hi,
    I have a scenario where I am using :
    EXECUTE IMMEDIATE 'UPDATE TEST1 SET NAME='ABC' WHERE CODE='001''
    I want to know how many records updated using EXECUTE IMMEDIATE
    Any help will be needful for me
    Edited by: user598986 on Sep 23, 2009 3:33 AM

    user598986 wrote:
    I want to know how many records updated using EXECUTE IMMEDIATESame as usual - SQL%ROWCOUNT:
    SQL> set serveroutput on
    SQL> begin
      2  execute immediate 'update emp set sal=sal where ename = ''KING''';
      3  dbms_output.put_line(sql%rowcount);
      4  end;
      5  /
    1
    PL/SQL procedure successfully completed.
    SQL> SY.

  • How do I update podcasts on windows computer?It used to do it automatically each time I tunes was opened

    how do i update podcasts on my computer?  they used to put current versions each time i opened I tunes

    You don't update itunes on your phone, you update itunes on your computer.

  • I upgraded from 3gs and want to use my old 3gs as an ipod. how can i update my new apple ID on the 3gs as it still shows a previous one that I had?

    I recently upgraded from 3Gs to Iphone4 and want to use my old 3Gs as an ipod. how can i update
    the user ID on the 3gs to a new one that I have as it is still showing a previous user ID?

    Settings>Store...tap the ID shown...sign out...sign back in with the ID you want to use.

  • How can we update data in LDAP server using PL/SQL.

    Hi,
    How can we update data in LDAP server using PL/SQL program.
    Is there any sample code for refrence.
    Thanks,
    Tarun

    Hi Justin,
    Thanks for your help. You got my correct requirements.
    Tim's example returning all the attributes of current user which is admin user. Please correct me if I am wrong.
    I have the following information:
    the admin user and password,server info , port and ldap_base for admin.
    I have uid and password for regular user, I am trying find the ldap_base for regular user, which may be different from adminuser.
    Please help me.
    Thanks,
    Edited by: james. on Jan 12, 2009 5:39 PM

  • How do i update my apps on my iphone using itunes 11.0.0.163

    How do i update my apps on my iphone using itunes 11.0.0.163

    I click update on the app or try to purchase an app and it asks for my password. I enter my password, the icon spins and then just goes back to saying update or purchase. I have tried resetting my settings and shutting my phone off and nothing has seemed to work.

  • How can I update my iPad 3 to iOS 6 using iTunes

    How can I update my iPad 3 to iOS 6 using iTunes

    Welcome to the Apple Support Communities
    See "Update your device using iTunes" > http://support.apple.com/kb/HT4623?viewlocale=en_US&locale=en_US

  • HT4623 How do I update my iphone 5 to the new ios7 software using itunes on my computer?

    How do I update my iphone 5 to the new ios7 software using itunes on my computer?

    Just for clarity, do you have iTunes 11.1 now on your computer?  If yes, when you connect your iPhone via your USB / Lightning cable is your iTunes opening with a small box near the top right of screen that shows your iPhone connected?  If yes then you can click through the various views of your iPhones content areas, such as Music, Photos, etc.  You will eventually get to a screen that is Status.  On that screen you should see the iOS Update option. 

  • How can i update my old 2006 iMac Intel core 2 duo running 10.6.8 to OSX Lion so that I can sync using iCloud with my newer devices?  Mountain Lion is not an option for my older model and Lion is no longer available at App store.

    How can i update my old 2006 iMac Intel core 2 duo running 10.6.8 to OSX Lion so that I can sync using iCloud with my newer devices?  Mountain Lion is not an option for my older model and Lion is no longer available at App store. 

    Call Apple's online store's telesales agents: 1-800-MY-APPLE (1-800-692-7753) or Customer Service and Sales Support at 1-800-676-2775. For Lion you'll get a redemptions code via e-mail and need to DL from the Mac Apple Store (requires SL 10.6.6+).

Maybe you are looking for

  • Doubt in Form Template Customization Using VSTA

    Hi All, i have doubt in InfoPath form development using VSTA. I have one form template, i want to auto fill(Using Hard coded) some of fields in that form like name,date and mobile number. Can any one help me out how to do that. Thanks in advance!

  • Typical BT, Get the BILL WRONG and then penalise m...

    Hi all Can anyone advise me how to get this problem sorted as I am fed up with being illegally overcharged and am no moving away from BT NEVER TO RETURN.... I had my last bill and was shocked as it was £111. All my calls and broadband are through SKY

  • Photoshop crashes during launch on mac platform

    It had been working fine up until today. I have not made any changes or updates with my computer. It is version CS4, I am on Mac 10.5.8 I tried de-installing and re-installing, did the 11.1 update, still won't open. It crashes before the photoshop te

  • How do I get RSS Feeds to work in Kerberos?

    Hi, I am migrating from sharepoint 2010 to sharepoint 2013. The SharePoint 2010 site used kerberos and I have kerberos working for the migrated site in 2013 (kerberos). However, the RSS feeds on front page show error An unexpected error occurred proc

  • Levels and button transparency

    Hello My first post and I've only been using Flash 8 for a short while so here comes the dumb questions. I have a swf file and a button on a page that opens another swf file in a new layer. I have found though that the buttons from the level below ca