Parallel query for UPDATE

Hi,
In the documentation of Oracle 10.2 -> Data Warehousing guide -> Ch.25 Using Parallel execution, search for section labeled "Rules for UPDATE, MERGE and DELETE", it is mentioned that,
"UPDATE, MERGE, and DELETE operations are parallelized by partition or subpartition. Update, merge, and delete parallelism are not possible within a partition, nor on a nonpartitioned table"
I am on 10.2 Enterprise edition, Solaris. I can see that, I can parallelize an UPDATE command (commands pasted below).
Please can somebody explain me, what am I missing ??
SQL> drop table r1 ;
Table dropped.
SQL> create table r1 as select * from user_objects where 1=2 ;
Table created.
SQL> exec dbms_stats.set_table_stats( ownname=>'solarp', tabname=>'R1', numrows=> 100000000, numblks=>251342 ) ;
PL/SQL procedure successfully completed.
SQL> alter table r1 parallel 5 ;
Table altered.
SQL> set autotrace traceonly explain
SQL> update r1 set status='XX' where created > ( sysdate - 7) ;
0 rows updated.
Execution Plan
Plan hash value: 1840129185
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
| 0 | UPDATE STATEMENT | | 5000K| 66M| 14083 (14)| 00:02:49 | | | |
| 1 | UPDATE | R1 | | | | | | | |
| 2 | PX COORDINATOR | | | | | | | | |
| 3 | PX SEND QC (RANDOM)| :TQ10000 | 5000K| 66M| 14083 (14)| 00:02:49 | Q1,00 | P->S | QC (RAND) |
| 4 | PX BLOCK ITERATOR | | 5000K| 66M| 14083 (14)| 00:02:49 | Q1,00 | PCWC | |
|* 5 | TABLE ACCESS FULL| R1 | 5000K| 66M| 14083 (14)| 00:02:49 | Q1,00 | PCWP | |
Predicate Information (identified by operation id):
5 - filter("CREATED">SYSDATE@!-7)
Thanks in advance

The manuals get out of date and out of synch. Somewhere in the 9i manuals it says that there is "limited" support for all parallel DML. Your plan, as David said, is a parallel select with serial update - if you want to perform the update in parallel then you need an explicit:
alter session enable parallel dml;Here's a plan (pulled from v$sql_plan in 10.2.0.3) for a similar update to yours. This plan is the parallel update version:
update t1 set n1 = 0 where mod(id,100) = 0
| Id  | Operation             | Name     | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
|   0 | UPDATE STATEMENT      |          |       |       |   753 (100)|          |        |      |            |
|   1 |  PX COORDINATOR       |          |       |       |            |          |        |      |            |
|   2 |   PX SEND QC (RANDOM) | :TQ10000 |   100 |   800 |   753   (0)| 00:00:10 |  Q1,00 | P->S | QC (RAND)  |
|   3 |    UPDATE             | T1       |       |       |            |          |  Q1,00 | PCWP |            |
|   4 |     PX BLOCK ITERATOR |          |   100 |   800 |   753   (0)| 00:00:10 |  Q1,00 | PCWC |            |
|*  5 |      TABLE ACCESS FULL| T1       |   100 |   800 |   753   (0)| 00:00:10 |  Q1,00 | PCWP |            |
Predicate Information (identified by operation id):
   5 - access(:Z>=:Z AND :Z<=:Z)
       filter(MOD("ID",100)=0)Note, particularly, that the UPDATE operation is the child of the PX SEND to coordinator. i.e. we update in the PX slaves, then tell the co-ordinator what we updated.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk

Similar Messages

  • Turn off Parallel Query for instance

    I have a new 10g RAC instance, on Windows 2003 64, which was just converted from 8i. It is currently a 1 node cluster. The database was built with parallelism turned on and now we are experiencing severe performance degradation. Quest spotlight keeps raising alarms regarding queries being forced to serialize. I have been told it would probably be better to turn parallelism off entirely (this is an OLTP instance). What parms and what settings do I need to set them to in order to shut of parallel query for the instance?

    There must have been a specific reason why it was built as an RAC database
    on a single node. Is it running 2 instances ?
    If there's no reason to be running RAC on a single node, you could shut down
    one instance.
    PARALLEL_MAX_SERVERS determines the maximum number of ParallelQuery
    processes (not PARALLEL_SERVER ! PARALLEL_SERVER what was for OPS).
    Either
    a) you really need Parallel Query Server processes for some user queries
    and PARALLEL_MAX_SERVERS is too low (forcing serialisation of queries)
    or
    b) you should not be using ParallelQuery
    b) is more likely for your OLTP environment.
    Therefore, you could disable parallelism at table level or set
    PARALLEL_MAX_SERVERS down to 0.

  • SQL Query for update

    hi experts
    I got two tables
    BOOK (DDC,TITLE,ISBN,AUTH_NAME)
    AUTHOR (ID,DDC,AUTH_NAME)
    AUTH_NAME column in BOOK's table contains NULL for all records.
    I want update table BOOK's column AUTH_NAME from AUTHOR's column in AUTHOR table where DDC numbers match. DDC is not unique in AUTHOR's table. I want to update BOOK table with the first matching AUTH_NAME. Rest should be ignored.
    Please write me the query for it.
    thanks

    Please write me the query for it.This fellow has no questions.
    Please, DO NOT ANNOY HIM with hints and tips, he just wants his answer. ; )
    I suspect it's homework, just another cheating student, earning his OCP.
    He is very anxious to get somebody to do his work, as he has spammed this same questtion on several other Oracle forums:
    http://dba.ipbhost.com/index.php?showtopic=10441
    http://www.dba-village.com/village/dvp_forum.OpenThread?ThreadIdA=32264

  • Query for Updation!!!

    Hi,
    I am working on some retail related.our client is having some vendors.so every month we are calculating the total sales about the products.
    Means we have "TotaL Current Sales" and Prevous "Month sales amt".
    By using these two we are preparing statements for that particular vendor for that particular month and the previous month.
    But the problem is am getting... when I am tryiyng to update the Previous MOnth amt it is getting updated but while preparing the statement it is showing the old value instead of new value.
    can you please help me out to resolve it.
    Eg : Current Month sales : 23,000,000
    Previous MOnth Sales : 13,000,000
    Here I have written the update statement to update the Previous month sales as 11,000,000.
    then it is showing the sales as 11,000,000.
    But while preparing the statement it is showing the Previous month sales as 13,000,000 only.But I want to display it as 11,000,000.
    can you please help me out to write a query or Procedure/Function or any thing which is required for this.
    Thanks in advance.

    Give us the following details.
    1. DB Version.
    2. Table structure
    3. Sample Data
    4. SQL Statement Executed by You.
    Use {noformat}{noformat} tags when you post the above details to preserve the code format.
    You can use it like this
    <your code here>\                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Query for updating prices if product IDs same

    I have a large Windows SQL 2000 database of products that
    need to have
    2007 prices.
    I have another Windows SQL 2000 database that has the correct
    prices
    that I can import into Windows SQL 2000 as a new table.
    I want to be able to UPDATE the Prices where product IDs
    match.
    What would an SQL query look like that would run in Query
    analyzer?
    So, basically, I need a query that would compare the product
    IDs and
    update the price column with the new price.
    Neither database is in the same location. One that holds the
    correct
    pricing is basically inaccessible to me. I can get a
    delimited file
    though. I know how to get that in.

    I've a table called Track, which has three columns named Part1, Part2 and Part3. I want all values of Part1 to be separated by a comma (,);
    No, don't go there.
    This breaks a fundamental point for relational databases: no repeating groups. A cell should hold an atomic value. And this is not only a matter of purism. Relational databases are designed from this principle, and breaking this means that you will need
    to write complex and higly inefficient code.
    The values in Part1 should be in a separate table, with one value per row.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Form on SQL query for updating.

    Hello again,
    Im trying to wirte a form to udapte the information in a table. I have a table with a PK which holds a persons name, and an activity assigned to them (and loads of other fields but they dont matter atm). I would like to have a form which has an SQL query running in one region and then the form underneath to be able to edit (reassign a person to a different activity) an item appearing in the query result. Ive got a form at the moment which is form on an sql query but its not updating when i fill out the form, is it something to do with the regions?
    http://img.photobucket.com/albums/v611/Funky_Monk/untitled.jpg
    So on the screenie, i have the bottom region for the query (no values in table hence the error (i think!))
    The call ID is FK to another table
    severity level and status will be usdated here
    description is self-explanitory
    analyst_id is the main field to be changed here, the call id will be assigned a new analyst via this form.
    action_id is actions carried out on this problem.
    Any help would be greatly appreciated.
    DM

    hi,
    Can you put this example on apex.oracle.com?
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • [Solved partially] Sql query for updates compliance

    Hello
    I'm trying (with no success) to translate the "Software+Updates+-+A+Compliance%2fCompliance+1+-+Overall+compliance" report into a sql query that must run for a specific
    Software update group and for a specific Collection ID.
    The expected result should be like the report it self, I mean 3 lines with Kpi (pourcentage).
    The main query in this report is : 
    select
    CollectionID=@CollID,
    Status=sn.StateName,
    cs.NumberOfComputers,
    PComputers=convert(float, isnull(cs.NumberOfComputers, 0)*100.00) / isnull(nullif(cs.NumTotal, 0), 1),
    AuthListID=@AuthListID
    from (select CI_ID, NumTotal, [0]=NumUnknown, [1]=NumPresent+NumNotApplicable, [2]=NumMissing
    from fn_rbac_UpdateSummaryPerCollection(@UserSIDs)
    where CI_ID=@CI_ID and CollectionID=@CollID
    ) cnt
    unpivot (NumberOfComputers for [Status] in ([0], [1], [2])) cs
    left join fn_rbac_StateNames(@UserSIDs) sn on sn.TopicType=300 and sn.StateID=cs.Status
    where cs.NumberOfComputers>0
    order by cs.NumberOfComputers desc
    I have no clue on how to replace or use fr_rbac view when run outside a report.
    Can you please help me ?
    Thanks

    Hi,
    Glad to hear that and thank you for your sharing.
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Need help to write a query for Update statement with  join

    Hi there,
    The following update statement gives me error as the given table in set statement is invalid. But its the right table .
    Is the statement correct? Please help .
    update (
           select distinct(vpproadside.VEHICLE_CRED_OVERRIDE.vin)            
             from vpproadside.VEHICLE_CRED_OVERRIDE
             join vpproadside.vpp_vehicle
               on vpproadside.vpp_vehicle.vin = vpproadside.VEHICLE_CRED_OVERRIDE.vin
            where VPP_CARRIER_SEQ_NUMBER = 90
              and EXPIRY_DATE = '17-MAR-10'
       set vpproadside.VEHICLE_CRED_OVERRIDE.EXPIRY_DATE = '15-SEP-10';Edited by: Indhu Ram on Mar 12, 2010 1:00 PM
    Edited by: Indhu Ram on Mar 12, 2010 1:22 PM
    Edited by: Indhu Ram on Mar 12, 2010 2:35 PM
    Edited by: Indhu Ram on Mar 15, 2010 8:04 AM
    Edited by: Indhu Ram on Mar 15, 2010 8:06 AM
    Edited by: Indhu Ram on Mar 15, 2010 8:28 AM

    Ask Tom has very good discussion about this, if UPDATE does not work for PK issue, you can use MERGE
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:760068400346785797

  • Query for updating the records

    I have the two tables....
    CREATE TABLE temp_1
    ( ST_NM VARCHAR2(30),STATUS_ID VARCHAR2(1) NOT NULL ENABLE,ST_ID VARCHAR2(20) primary key,REJ_USER_NM varchar2(10))
    sample Data :
    insert into temp_1 values('S010054','R','ST9749109','TEST_1');
    insert into temp_1 values('S010179','R','ST9749147','');
    insert into temp_1 values('S010582','N','ST9749258','');
    CREATE TABLE temp_2
    ( REJ_USER_NM VARCHAR2(20),ST_NM VARCHAR2(30),
    STATUS_ID VARCHAR2(1) NOT NULL ENABLE,ST_ID VARCHAR2(20))
    sample data:
    insert into temp_2 values('','S010054','N','ST9749109');
    insert into temp_2 values('','S010054','N','ST9749109');
    insert into temp_2 values('TEST_1','S010054','N','ST9749109'');
    insert into temp_2 values('','S010054','I','ST9749109');
    insert into temp_2 values('','S010179','N','ST9749147');
    insert into temp_2 values('TEST_2','S010179','N','ST9749147');
    insert into temp_2 values('','S010179','N','ST9749147');
    insert into temp_2 values('','S010179','N','ST9749147')
    insert into temp_2 values('TEST_5','S010582','R','ST9749258');
    insert into temp_2 values('TEST_5','S010582','N','ST9749258');
    insert into temp_2 values('','S010582','N','ST9749258');
    insert into temp_2 values('','S010582','N','ST9749258')
    I want the UPDATE query based on below conditions to update the REJ_USER_NM in temp_1 table.
    From temp_1 table ,STATUS_ID is 'R' and REJ_USER_NM is null and compare the set_id column value
    with the temp_2 table,where REJ_USER_NM is not null and status id is 'N'. REJ_USER_NM column from
    temp_2 table need to be update in the REJ_USER_NM column of temp_1 table.
    After completion of updation,output is in below format; if i run below qry
    ====================================
    select * from temp_1;
    {S010054},{R},{ST9749109},{TEST_1}
    {S010179},{R},{ST9749147},{TEST_2}
    {S010582},{N},{ST9749258},{}
    ======================
    Edited by: 849971 on May 2, 2011 8:25 PM

    Why is that the row
    {S010582},{N},{ST9749258},{}
    is not updated to TEST_5 ?? Based on your rules and data. it must be updated to test_5. Are you missng any rules?
    Try some thing like,
    UPDATE temp_1
       SET REJ_USER_NM  =
              (SELECT REJ_USER_NM
                 FROM temp_2
                WHERE     status_id = 'N'
                      AND temp_1.st_id = temp_2.st_id
                      AND temp_2.REJ_USER_NM IS NOT NULL)

  • Need Query for Update

    CREATE TABLE TEST_MATCH
    MTCH1 NUMBER(9),
    MTCH2 NUMBER(9),
    UPDT_MTCH CHAR(2 BYTE),
    UPDT_NBR NUMBER(10)
    SET DEFINE OFF;
    Insert into TEST_MATCH
    (MTCH1, MTCH2, UPDT_MTCH)
    Values
    (2616131, 300137070, '02');
    Insert into TEST_MATCH
    (MTCH1, MTCH2, UPDT_MTCH)
    Values
    (2571056, 300129277, '02');
    Insert into TEST_MATCH
    (MTCH1, MTCH2)
    Values
    (2623529, 300175046);
    COMMIT;
    i need to update the column UPDT_NBR which is currently NULL
    UPDATE TEST_MATCH
    SET UPDT_NBR =
    NVL(2616131, 300137070) FOR THESE TWO MATCHES-> (1234567),
    (2571056, 300129277) FOR THESE TWO MATCHES -> (1111111),
    (2623529, 300175046) FOR THESE TWO MATCHES ->(222222);
    Thanks for all your help in my previous post. And thanks again for looking into my post.

    Hi,
    If it is just three records it would be better if you fire individual update statement 3 times.
    But if it is a sample data only and you have many updates to do then only way I think it is is possible is either by creating temporary table or using subfactoring(same as creating temporary table)
    Regards
    Anurag

  • SQL query for updating values in same cell of a table

    Hi All,
    I'm stuck with a problem and it stands as follows:
    Table name: Track
    Part1  Part2  Part3
    NULL   NULL   NULL
    I've a table called Track, which has three columns named Part1, Part2 and Part3. I want all values of Part1 to be separated by a comma (,); it should not be overwritten, neither they should appear in separate row, in fact they should look like this:
    Part1    Part2    Part3
    1,2,3    5          SUBM1
    The new values of Part1 should appear in next row only when value of Part3 changes, so if Part3 changes from SUBM1 to SUBM2, it should look like this:
    Part1    Part2    Part3
    1,2,3    5          SUBM1
    1,2,3    5          SUBM2
    Count of values in Part1 never exceeds the value of Part2, so if Part2 is 5, then Part1 will look like 1,2,3,4,5. So in other words loop will run only up to the value of Part2.
    Please advise how this could be achieved?
    Kind regards,
    Aniruddha Jagdale

    I've a table called Track, which has three columns named Part1, Part2 and Part3. I want all values of Part1 to be separated by a comma (,);
    No, don't go there.
    This breaks a fundamental point for relational databases: no repeating groups. A cell should hold an atomic value. And this is not only a matter of purism. Relational databases are designed from this principle, and breaking this means that you will need
    to write complex and higly inefficient code.
    The values in Part1 should be in a separate table, with one value per row.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Query for update

    . I have a table with a column city. The values are delhi and banglore. I need to update banglore with delhi and delhi with Banglore

    shiv kumar wrote:
    . I have a table with a column city. The values are delhi and banglore. I need to update banglore with delhi and delhi with Banglore
    update <table> set city = 'X' where city = 'banglore'
    update <table> set city = 'banglore' where city = 'delhi'
    update <table> set city = 'delhi' where city = 'X'
    /

  • For Update Query

    Hi All,
    I having block level 8000 records, I Scroll down from First record to last record it is takeing more time.
    I Observed tkproof while scrolling two select statments are running..
    1) pre-query block level
    2) For update query
    For update query -> How is is forming? Any Property or some else?
    I am not able to find the second query..where it is forming..How to restrict the second query.
    Query Array size - 10
    Number of records buffered - 10
    Number of records Displayed - 10
    Query all records - No
    Locking mode - Immediate
    Key mode - Automatic
    Version - Oracle 10g
    Plz ........any

    The for update -query is generaetd by forms when its locking the record. If you didn't change anything in the record "by hand", check if there is some code in the POST-QUERY-trigger which forces the record to be locked. if its the POST-QUERY you can issue the following command to avoid the lock at the end of the POST-QUERY:
    SET_RECORD_PROPERTY(:SYSTEM.TRIGGER_BLOCK, :SYSTEM.TRIGGER_RECORD, STATUS, QUERY_STATUS);

  • Oracle 10g and parallel query question

    Hi Oracle on SAP Gurus!
    We are currently thinking of activating parallel query for certain segments (large application tables and indexes). We searched in SAPNet and SDN and have also studied the SAP Note 651060. But we did not find a complete answer to the following question which is very important for us:
    Which kinds of queries (despite from full table scan and index scan in partitioned indexes) support parallel queries and which ones do not support parallel queries?
    This is important for us to find out whether we have candidates for parallel queries or not.
    Thanx for any hint!
    Regards,
    Volker

    But why do you not propose to use parallel query in OLTP systems?
    If the queries are accessed very frequently you will just run out of cpu and io ressources. OLTP systems are (historical) typically multi user systems. You can off course use PQ for 'single user' activities, like index rebuilds, some batchjobs, but you shouldn't do for frequent user queries.
    If you have time look at this interesting Article [Suck It Dry - Tuning Parallel Execution|http://doug.burns.tripod.com/px.html]
    It is quite old, and you don't have to read all tech details, but i recommend having a look at the conclusions at the end.
    May it make sense to use partitioning of these tables in conjunction with parallel query?
    I know some guys, who do partitioning on OLTP systems, even SAP systems. But they don't use PQ then. The use partitioning to work on a smaller set of data. In your case the range scans, would need to scan only one partition, saving buffer cache and effectively speeding up execution. So you don't need PQ to scan all partitions at all, this would be a typical OLAP approach.
    Best regards
    Michael

  • What is the query to update table in ejb3.0

    Hi Friends,
    I am developing one application using ejb3.0 in Netbeans IDE 6.7.1 with Glassfish Application server.
    To insert data we use "entitymanager.persist(Insert insert);"
    To retrieve all data from table "entitymanager.createQuery("")'
    In the same way what is the query for update?
    Could you please help me.
    Thanks in advance.

    [the answer|http://lmgtfy.com/?q=java+jpa+udpate+query]

Maybe you are looking for

  • Error on installing iTunes under Win 8

    Error on installing iTunes under Win 8 I have recently upgraded to Win 8.  When installing iTunes the following error shows: "An error occurred during the installation of assembly 'Microsoft.VC80.CRT.type="win32",version"8.0.50727.4053.publicKeyToken

  • Make any sense out of crash report?

    Hello- Since upgrading to Yosemite FCP is not usable. Slow to the point of not being usable. If anyone can see anything in this report that I might be able to fix/work on I would be grateful. Thank you. Process:               Final Cut Pro [468] Path

  • Create a New Report Server in Oracle 10g AS(10.1.2.0.2) in IBM-AIX

    Hi Friends, I am using Oracle 10g AS(10.1.2.0.2)on IBM-AIX. I would like to create a new Report Server(standalone).Please suggest and give the Metalink Document Number as well. Regards, Arun

  • I need some advice on some laptops

    I'm looking to buy a laptop for the first time, I want to run good graphic games and I have a price range of 400-650 and wanted to know would this be a good choice? If not could someone please post one that would be good for what I am looking for htt

  • HT5631 security questions - how to change them "for good"

    The process to change the security questions is extremely confusing. Your instructions on apple support are not complete. You suggest to click on a button to turn off a two-step verification but that button does not exist.