Faster than SQL PL/SQL!

Hi people

Really, I try to avoid complex code and I perfer SQL, PL/SQL whenever possible. Normally this is not not just easier, but also a lot faster.

I now have a problem if this is not the case.
When I update the data in a table with a simple UPDATE... WHERE the command, it takes twice as long as an update of PL/SQL on the ROWID.

I get the exact moment when I select UPDATES.


Even just identify 1 row, a SELECT for UPDATE takes twice the time as a simple SELECT statement. (FULL table Scan)

So I belief overload is due to the LOCK ORACLE updates all rows affected.
Am I right on that? Can someone point me to the documentation on that? Is there an ORACLE statistics where I see most in resource consumption?

See my example below. This creates a table with no index 100 000 000 lines. Any clue would reduce the number of lines 'touched' and make the less obvious test.

Calendar is different on each system, but the effect should be as well.
I'm using ORACLE 11.2.0.4.5 on Solaris 10 x 64

Thanks for your comments.
Andy

Example:

create table join1
(my_pk number,
 key_1  number,
 key_2  number,
 key_3  number,
 key_4  number,
 key_5  number,
 key_6  number,
 key_7  number,
 key_8  number,
 key_9  number,
 key_10  number,
 data    varchar2(1000));

insert into join1 select * from (
WITH data1 AS
(SELECT level key_1, level + 23351 key_2, level + 56512 key_3, level + 21 key_4, level + 99433 key_5
           FROM DUAL
     CONNECT BY LEVEL <= 10000)
select rownum my_pk,
        a.key_1, a.key_2,  a.key_3, a.key_4, a.key_5, b.key_1 key_6, b.key_2 key_7,  b.key_3 key_8, b.key_4 key_9, b.key_5 key_10
       ,'Just to fill data in .... ' datax
from data1 A
cross join data1 B
);
commit;
begin
DBMS_STATS.GATHER_TABLE_STATS (
   ownname          => user,
   tabname          => 'JOIN1',
   estimate_percent => 10,
   block_sample     => TRUE,
   degree           => 12,   
   cascade          => TRUE);
end;
/

Tests:
select * from join1 where key_1=500 and key_2=23851 and key_3=57012 and key_4=521 and key_6=1 and key_7=23352;
-- 7 sec

select * from join1 where key_1=500 and key_2=23851 and key_3=57012 and key_4=521 and key_6=1 and key_7=23352
 for update;
-- 13sec 

update join1
 set data = data||'#'
 where key_1=500 and key_2=23851 and key_3=57012 and key_4=521 and key_6=1 and key_7=23352;
rollback;
-- 13sec

update join1
 set data = data||'#'
 where rowid in (select rowid from join1 where key_1=500 and key_2=23851 and key_3=57012 and key_4=521 and key_6=1 and key_7=23352);
rollback;
-- 13sec

DECLARE
  TYPE rowid_type              IS TABLE OF UROWID INDEX BY BINARY_INTEGER;
  tab_rowid                    rowid_type;
  lv_rows_updated              number :=0;
  CURSOR my_cursor IS
    SELECT rowid rid FROM join1 where key_1=500 and key_2=23851 and key_3=57012 and key_4=521 and key_6=1 and key_7=23352; 
 
BEGIN
  OPEN my_cursor;
  FETCH my_cursor
        BULK COLLECT INTO tab_rowid
        LIMIT 10000;
  FORALL lv_row IN tab_rowid.FIRST .. tab_rowid.LAST
         update join1 set data = data||'#' where  rowid = tab_rowid(lv_row);
      lv_rows_updated := SQL%ROWCOUNT;
   ROLLBACK;
  CLOSE my_cursor;
END;
/
-- 7sec

I repeated the effect.

I limited the number of lines to 16.000.000 who gave me a table of 185 000 8 KB blocks; then I put the buffer of about 32 000 blocks cache (to make sure that the table was at least 5 times the size of the cache).

In my test code, I ran the simple select twice and collected different performance figures, otherwise, I just copied your code.

Here are the important numbers:

Select (1)

----------

CPU used by this session 71

DB time 331

physical direct bed 185 764

Select (2)

----------

CPU used by this session 71

DB time 325

physical direct bed 185 764

Select Update

-----------------

CPU used by this session 147

DB time 528

physical reads cache 185 764

Update (1)

----------

CPU used by this session 132

DB time 471

physical reads cache 164 883

Update (2)

----------

CPU used by this session 135

DB time 474

physical reads cache 164 865

Strategy of PL/SQL

---------------

CPU used by this session 79

DB time 327

physical direct bed 185 764

The select for update and update options through the cache so CPU upgrades.

Simple selection (which includes your pl/sql) bypasses the cache, reducing the CPU.

Because my equipment does not match yours, it is not surprising that the time I/O have had a greater impact on the total duration of the DB.

Your result is a by-product of the analysis, being able to run with readings of direct path for a simple select statement.

Concerning

Jonathan Lewis

Tags: Database

Similar Questions

  • Why is the 'UNION' statement faster than 'OR' sometimes?

    Many articles say that the 'UNION' statement can make the SQL statement run faster than "GOLD" awhile. However, why is the 'UNION' statement faster than 'OR' some time? Why does CBO sometimes choose 'UNION', not 'GOLD'.

    Hello

    If you have a select statement like this

    Select * from my_table where col1 like "something %' or col2 like '% else';"

    and there is an index on col1 and an index on col2. It may be a good idea to chosse a union. This is just an example.

    Best regards

    Thomas

  • Why is developer of Firefox more stable and faster than ordinary Firefox?

    So, I have some great experiences with regular Firefox. It works great themes, beautiful, good plugins, security etc., but there is one thing that bothers me in Firefox on ALL computers on EACH operating system. Whenever I have install Firefox, it is already slow, he stutters sometimes and sometimes it freezes. And this isn't just my problem because many of my friends and classmates using Chrome right now they complain about the speed of Firefox. Now, for me it is not a problem, I'm not a patient person, but it certainly is the browser that will protect my privacy rather than Chrome.

    Recently, somewhere, I saw download link saying something like "Developer Mozilla, for people like you", or something like, I installed and the man, the browser is like 10 x faster than regular Firefox AND Chrome AND Safari, I mean, this speed is outrageous! It's great, no sarcasm!

    I don't get, why is so slow regular Firefox and Firefox Developer so frickin' fast? Why? Perhaps, you can base your next update of Firefox to the developer of Firefox?

    Sincerely in love with developer of Mozilla Firefox. * muah *.

    Firefox Developer Edition is a version of Firefox. So what you see in the developer edition is coming out to regular Firefox in about 12 weeks (we releases every 6 weeks, and Dev edition is two versions before publication)

    Dev Edition also uses a fresh profile, which may be faster than your old profile which is full of old data.

  • Why Chrome load websites faster than Firefox

    I can load a website at least two times faster than Firefox Chrome. Why?

    Hello

    The reset Firefox feature can solve a lot of problems in restaurant Firefox to its factory default condition while saving your vital information.
    Note: This will make you lose all the Extensions, open Web sites and preferences.

    To reset Firefox, perform the following steps:

    1. Go to Firefox > help > troubleshooting information.
    2. Click on the button 'Reset Firefox'.
    3. Firefox will close and reset. After Firefox is finished, it will display a window with the imported information. Click Finish.
    4. Firefox opens with all the default settings applied.

    Information can be found in the article Firefox Refresh - reset the settings and Add-ons .

    This solve your problems? Please report to us!

    Thank you.

  • Have several active applications drain battery faster than to have just an active app?

    Have active several apps at the same time drain battery faster than to have just an active app at the same time?

    On an iDevice you have only one active application at any time in time. Applications is displayed when you click the home button twice are not active until you click on them.

    See you soon,.

    GB

  • Clean install of Windows a lot faster than the preinstalled system?

    My satallite comes with windows 64-bit installed.
    Since a lot of people suggested, here and elsehwere, a clean installation making consierably faster than the pre-installed windows (all bloated and unwanted software uninstalled with the uninstall program).

    Although fresh installtion was faster without drivers and programs, it has become more or less the same after installation of all software, etc. (perhaps a difference of 2 to 4% in the use of RAM) (over 4 GB)

    Is this normal or do others go much faster on any new install, for me, this effort has proved there is not a lot of use to do a clean install to drive retail.

    Ideas, wiers and feed back?

    See you soon

    Many pre-installed utilities are required for correct functionality and it can be a headache get these functions to work after installing a street copy of Windows.

    You will find that when you install Antivirus software on a street copy of Windows, it will happen similar to the pre-installed Windows installation. So if you want that the installation of Windows pre-installed perform better, uninstall the Antivirus should do the trick.

  • R7000 Nighthawk Wired is faster than the wireless

    I currently use a Nighthawk R7000 and after the speed test internet using speedtest.net, I found that a desktop computer that is connected directly with ethernet is more than 100 Mbps faster than a wireless laptop which is the only room away from the router (wired office gets 140 ~-~ 160 Mbit/s, while the laptop is ~ 30-40 ~ Mbps). Any help would be great.

    Thanks to all who tried to help, but he had a friend IT of my father who came and said: it's a certain chip (or something of the kind) in my computer that was wrong, so we got a Linksys adapter Max - Stream AC600 WiFi Micro USB. I can now get 90 Mbits/s download. Thanks again for everyone's help.

  • faster than El Capitan Windows 10

    Hello

    I have a 13 "mid-2013 Macbook Air 128SSD / 8 GB/Intel i5.

    I tried the two El Capitan and Windows (via Bootcamp) 10 and Windows runs faster than Mac for a reason any.

    Launching applications faster and overall, it feels snappier and more responsive.

    How is it possible that Windows can run faster on my Macbook as the own Apple operating system?

    Systems running different programs using different device drivers. 'Feel' is a very subjective measure. My windows running in Boot Camp "feels" faster than Windows running on a Windows PC. My El Capitan "feels" faster than my Windows running in Boot Camp 10.

  • Is faster than the HP Mini 110 Microsoft Surface?

    My HP Mini 110 series netbook is SLOW and it is 2 years old and the Microsoft Surface seems newer, but I want to know if the Microsoft Surface would go faster (for example, loading programs and files, etc.)

    The HP Mini 110 has an Intel Atom processor and the Microsoft Surface has an ARM processor.

    The Microsoft Surface would be faster than the HP Mini 110?

    It must be such that it is a newer CPU, but until the Surface is in the hands of consumers, we do not have really the real world benchmarks. I am 100% sure that whatever that is released by Microsoft or others would show much faster and better in all aspects. But these are marketing people making conversation, not technicians running the real numbers.

  • Games run too fast! (Faster than normal around 1.5 x)

    Hey I have problems playing games since the installation of W7.

    I tried only two games, which is Half Life: counter-strike 1.6 through Steam and Batman Arkham Asylum.
    From what I see, I shoot and walk faster in CS 1.6, when I play on my own. But when I join a server on Steam, I go fast, Yes, and then I will be stuck (I guess because the server will try to match my speed with others)
    In Batman: AA, I was comparing Youtube videos with my game and found that my Batman works faster than in the videos.
    Here's my DX System Info:
    ------------------
    Information System
    ------------------
    Time of this report: 11/16/2009, 22:21:27
    Name of the computer: PC
    Operating system: Windows 7 Professional 32 - bit (6.1, Build 7600) (7600.win7_rtm. 090713-1255)
    Language: English (regional setting: English)
    System manufacturer: GBT___
    System model: AWRDACPI
    BIOS: Award BIOS v6.00PG Modular
    Processor: Intel (r) Core (TM) 2 CPU 6400 @ 2.13 GHz (2 CPUs), ~2.1GHz
    Memory: 3072 MB RAM
    Available OS memory: 3072 MB RAM
    Page file: 1613MB used, 4527 MB of available space
    Windows Dir: E:\Windows
    DirectX version: DirectX 11
    DX setup parameters: not found
    DPI setting: Using System DPI
    System DPI setting: 96 DPI (100%)
    DWM DPI Scaling: disabled
    DxDiag Version: 6.01.7600.16385 32 bit Unicode
    I'm also running on a map of XFX9600GTXXX, with 8 x AA and AF, with Vsync off (must be turned off to reach 100 fps in CS, which I play competition)
    Tried solutions:
    I've been Googling for answers for almost 3 days without getting anything. I tried Winthrottle to slow down my CPU, defining my affinity proc at the base, and it does not work.
    (Although the speed improved to Batman, but running it on a carrot is terrible - did not work for CS)
    Turning on vsync seems to make it acceptable, but I'll be capped at 75 FPS.
    I need 100 fps on CS, because the response of the mouse is better.
    I was restoring my nvidia, same drivers try the new Forceware, nothing helps.
    I can't reformat my HD, but only not to do so due to college.
    These Core Dual optimizers, that I read are only for the amendments, I guess, so I can't do anything to this topic and it seems to be no fix.
    If anyone knows, I would like to know what is causing this = /

    It could well be your network drivers.  Even if you later, sometimes people writing the drivers need to improve for questions like yours that described and so you should keep a watch last updated driver.  On my laptop, for example, constantly Dell publishes new drivers for it that problems are discovered and updated correctly to handle Windows 7.  While it works great, they discover problems that may affect performance.

    Have you read anything in the counter-strike forums about anyone else having a similar problem?

  • Responsiveness of Windows XP is much faster than Windows 7

    According to this video

    http://www.YouTube.com/watch?v=Ay-gqx18UTM

    and MY personal experience, the xp desktop responsiveness is so much faster and less glitchy than windows 7 (e.g. open services.msc and play with the window, you will see black borders).

    You guys are going to solve this problem on Windows 8, to finally defeat xp in all aspects?

    Original title: why Microsoft, why?

    I have the same specification as Palcouk outside the video. Mine is a HD4250 integrated ATI and I get the black border.

    It may be safe to pin this one on the video card and drivers reasonbly

    Yes and also view the video uses Win 7, RTM, as in no current.

    I use two operating systems on Dells reasonably comparable...  I would say that in my experience 7 is faster than XP and not at all what I would call "glitch."
  • Why disable SuperFetch on ssd, if the RAM is much faster than the ssd?

    Directed by Microsoft that SuperFetch and PreFetch must be disabled, if the OS is installed on an ssd, in accordance with article http://support.microsoft.com/kb/2727880. But SuperFetch is used for loading the data components of applications, which were very often used for RAM. Although the ssd is faster that a hard drive is not faster than the RAM. So, I do not understand why Microsoft suggest disabling this feature. The only reason why I want to understand, it's because of a limited RAM. If the RAM is sufficient beyond 6 GB, if we disable SuperFetch, then the boot time and increase the loading time of most used applications. I miss something here?

    The other question is about PreFetch. I feel, maybe wrong, it does the same thing with SuperFetch, with one major difference. It loads all the information data on the ssd or hard drive, instead of the RAM, in order to accelerate the launch of applications and time when the OS is installed on a hard drive to boot. If I'm right, let's disable the PreFetch it stores information for one ssd or hdd, while SuperFetch stores data of RAM information, which is much faster and so it must be enabled if there is a sufficient RAM.

    I look forward to reading the notice of a Microsoft software engineer.

    Hi Leventis,

    Prefetch copies frequently accessed files together into a contiguous on the disk area so that they can be located and loaded more quickly. That it takes a lot of old drives to recover data faster.

    SuperFetch predict what applications you run next and preload all the necessary data in the memory. She has also done that with startup files. And for all the three days he sends a defragmentation command to the OS drive that will cause problems in the SSD drives.

    In traditional hard drives (HDD) data are scattered throughout the disk, so that the operating system for access, it will take more time. It is suggested to perform a disk defragmentation. But storage technology is different in SSD, where, it records the data dynamically and it recovers more quickly. Who will be low down the burden on the RAM and the RAM can be used for uses such as for the opening of the games graphics high-end, etc..

    Hope this information is useful.

  • Is faster than the local AIR IOS app remote SWF SWF because I can ' t use the unloading code.

    Are faster than the local SWF on AIR IOS app remote SWF because I can't use the code to unload on IOS of AIR.

    my local code:

    Stop();

    import flash.net.URLRequest;

    import flash.system.ApplicationDomain;

    import flash.system.LoaderContext;

    import flash.filesystem.File;

    import flash.filesystem.FileMode;

    import flash.filesystem.FileStream

    go_level_2.addEventListener (MouseEvent.Click, Level_2);

    function level_2(event:MouseEvent) {}

    var loader2:Loader = new Loader();

    var loaderContext2:LoaderContext = new LoaderContext (false, ApplicationDomain.currentDomain);

    var file2:File = File.applicationDirectory.resolvePath ("level2.swf");

    loader2. Load (new URLRequest (file2.url), loaderContext2);

    addChild (loader2);

    }

    Because it works for me, because I can't unload the SWF app file en becomes slow, I'll put the SWf file "s on a remote location.

    But I can't imagine what is happening when I loaded the SWF file remotely. It remains on the server, or it remains on my application when I unloaded it, and the app gets also larger. I hope you can help me because I went on the internet for a week and do not now how to go further.

    I had a similar problem, but not on iOS.

    Maybe my solution might work for you too, however.

    The problem was this line:

    new LoaderContext (false, ApplicationDomain.currentDomain);

    Do not reuse the same field of application, or you will never be able to get rid definitions and thus the SWF loaded.

    Instead, make a new child application domain for the current domain, keep track of it and it has as well as the rest of the SWF file when you are finished.

    Example:

    var loader2:Loader = new Loader();

    var appDomain2:ApplicationDomain = new ApplicationDomain (ApplicationDomain.currentDomain);

    var loaderContext2:LoaderContext = new LoaderContext (false, appDomain2);

    var file2:File = File.applicationDirectory.resolvePath ("level2.swf");

    loader2. Load (new URLRequest (file2.url), loaderContext2);

    addChild (loader2);

    Then

    function finishLevel2(event:Event):void

    {

    var loader2:Loader;

    loader2 = Event.Target.Loader;
    loader2.parent.removeChild (loader2);

    loader2.unloadAndStop ();

    appDomain2 = null;

    }

    Note that the definitions of the classes of the loaded SWF file will be available in the new application domain.

  • Why preview is rendered faster than the actual speed of my clips?

    When I create a new project, the overview of my project "plays" faster than the speed of the video. As it is fast forward. Each of the speed of clips are 100%.

    I tried to uninstall and reinstall the first but still have the same problem.

    Any idea? Thank you

    sample rate is 48 kHz

    Some people set their entry to 'none', but I do not see as to how that is going to change anything

  • is it possible that an application on a virtual machine is faster than in its host?

    To measure the performance of our software on vmware, compare us the performance of vm compared to its host machine.

    We found that performance on three different machines showed a very different behavior, of 50% slower at 10% slower.

    And the strangest thing is that there is a single machine, his vm is faster than its host.

    Any help on the possible reasons is appreciated!

    Thank you!

    Additional information:

    The application is time CPU,.

    CentOS 6.2 for the vm and host,

    VMware Workstation 10.0.1 build-1379776

    Hardware Dell R720VM vs host
    Xeon 2 CPU E5-2620 0 @ 2.00 GHz 12-Core, 32 GB-50%
    Xeon 2 E5-2650 V2 2.60 GHz, 16 Core CPU, 32 GB-10%
    Xeon 2 E5-2630 0 @ 2.30 GHz, 12 Core CPU, 64 GB20%

    After eliminating the various factors, we finally understood the cause: hyper threading

    After that we switched off the hyper threading, everything became normal, the slower and faster virtual machines showed same performance.

    Host performance has even improved, about 10-20% faster than the virtual machine.

    Hope that this experience and this information can be useful for others in the future...

    Thanks for your help during our survey!

Maybe you are looking for

  • How to remove the rest of the money in your itunes account?

    How to remove the rest of the money in your itunes account?

  • Bug when changing e-mail addresses

    I have changed email addresses and had no problem to update my Microsoft account. However, when you try to change my old e-mail to my new Skype, the password box insists that I mistyped my password. I am sure that I did not, and to confirm I've tempo

  • HP Stream: Connect and then black screen

    Just bought the HP flow last night for my daughter. We on that last night for about 10 minutes and then it turned off. Today, when I buy on this subject, we shot it, enter a name for the connection and then the screen goes all black. If we hit ctrl/a

  • Error message - Windows cannot open this file after downloading program

    After several days in offline mode, I went online to update Microsoft Security Essentials and click on analysis complete.  It took an hour.  After that, I found that all my programs were virgins, almost of all of the standard microsoft Microsoft Secu

  • No sound on T61p after going to Windows 7

    I installed Windows 7 RC build and lost all sound. I looked around, but it doesn't seem like there is still a driver out. Is this correct? I tried to install the latest driver (6.10.2.5510) in Vista compatibility mode, but that did not help either. W