Commit after select?

Is it necessary give commit after each SELECT in oracle? Can it influence performance of database (SELECTs without commit)?
Thank you for answer.
Lenka

Hello
I would imagine it is a artifact from using SQL server or DB2 or something similar. For certain transaction isolation levels, SQL server (for example) has to lock the rows being queried so that a consistent view of data can be returned, so committing after a select ensures that these locks are removed allowing others to read and write the data.
Oracle handles things differently, writers don't block readers and readers don't block writers. It is all part of the multi version read consistency model which is covered in the concepts guide. There are also some very interesting articles on asktom:
http://asktom.oracle.com/pls/ask/f?p=4950:8:10261219059254362776::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1886476148373
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/c01_02intro.htm#46633
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96524/c21cnsis.htm#2414
HTH
David

Similar Messages

  • Commit after a select query

    Do we need to commit after a select statement in any case (in any transaction mode)?
    Why do we need to commit after selecting from a table from another databse using a DB link?
    If I execute a SQL query, does it really start a transaction in the database?
    I could not find any entry in v$transaction after executing a select statement which implies no transactions are started.
    Regards,
    Sandeep

    Welcome to the forum!
    >
    Do we need to commit after a select statement in any case (in any transaction mode)?
    >
    Yes you need to issue COMMIT or ROLLBACK but only if you issue a 'SELECT .... FOR UPDATE' because that locks the rows selected and they will remain locked until released. Other sessions trying to update one of your locked rows will hang until released or will get
    >
    ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
    >
    In DB2 a SELECT will create share locks on the rows and updates of those rows by other sessions could be blocked by the share locks. So there the custom is to COMMIT or ROLLBACK after a select.
    >
    Why do we need to commit after selecting from a table from another databse using a DB link
    >
    See Hooper's explanation of this at http://hoopercharles.wordpress.com/2010/01/27/neat-tricks/
    And see the 'Remote PL/SQL section of this - http://psoug.org/reference/db_link.html
    A quote from it
    >
    Why does it seem that a SELECT over a db_link requires a commit after execution ?
    Because it does! When Oracle performs a distributed SQL statement Oracle reserves an entry in the rollback segment area for the two-phase commit processing. This entry is held until the SQL statement is committed even if the SQL statement is a query.
    If the application code fails to issue a commit after the remote or distributed select statement then the rollback segment entry is not released. If the program stays connected to Oracle but goes inactive for a significant period of time (such as a daemon, wait for alert, wait for mailbox entry, etc...) then when Oracle needs to wrap around and reuse the extent, Oracle has to extend the rollback segment because the remote transaction is still holding its extent. This can result in the rollback segments extending to either their maximum extent limit or consuming all free space in the rbs tablespace even where there are no large transactions in the application. When the rollback segment tablespace is created using extendable files then the files can end up growing well beyond any reasonable size necessary to support the transaction load of the database. Developers are often unaware of the need to commit distributed queries and as a result often create distributed applications that cause, experience, or contribute to rollback segment related problems like ORA-01650 (unable to extend rollback). The requirement to commit distributed SQL exists even with automated undo management available with version 9 and newer. If the segment is busy with an uncommitted distributed transaction Oracle will either have to create a new undo segment to hold new transactions or extend an existing one. Eventually undo space could be exhausted, but prior to this it is likely that data would have to be discarded before the undo_retention period has expired.
    Note that per the Distributed manual that a remote SQL statement is one that references all its objects at a remote database so that the statement is sent to this site to be processed and only the result is returned to the submitting instance, while a distributed transaction is one that references objects at multiple databases. For the purposes of this FAQ there is no difference, as both need to commit after issuing any form of distributed query.

  • Avoid Commit after every Insert that requires a SELECT

    Hi everybody,
    Here is the problem:
    I have a table of generator alarms which is populated daily. On daily basis there are approximately 50,000 rows to be inserted in it.
    Currently i have one month's data in it ... Approximately 900,000 rows.
    here goes the main problem.
    before each insert command, whole table is checked if the record does not exist already. Two columns "SiteName" and "OccuranceDate" are checked... this means, these two columns are making a unique record when checked together with an AND operation in WHERE clause.
    we have also implemented partition on this table. and it is basically partitioned on the basis of OccuranceDate and each partition has 5 days' data.
    say
    01-Jun to 06 Jun
    07-Jun to 11 Jun
    12-Jun to 16 Jun
    and so on
    26-Jun to 30 Jun
    NOW:
    we have a commit command within the insertion loop, and the each row is committed once inserted, making approximately 50,000 commits daily.
    Question:
    Can we commit data after say each 500 inserted rows, but my real question is can we Query the records using SELECT which are Just Inserted but not yet committed ?
    a friend told me that, you can query the records which are inserted in the same connection session but not yet committed.
    Can any one help ?
    Sorry for the long question but it was to make u understand the real issue. :(
    Khalid Mehmood Awan
    khalidmehmoodawan @ gmail.com
    Edited by: user5394434 on Jun 30, 2009 11:28 PM

    Don't worry about it - I just said that because the experts over there will help you much better. If you post your code details there they will give suggestions on optimizing it.
    Doing a SELECT between every INSERT doesn't seem very natural to me, but it all depends on the details of your code.
    Also, not committing on time may cause loss of the uncommitted changes. Depending on how critical the data is and the dependency of the changes, you have to commit after every INSERT, in between, or at the end.
    Regards,
    K.

  • Comma without preceding colon (after SELECT ?)

    Hi,
    I'm rather new to ABAP and only know some basics, and I ran into an error that I can't solve, must be something stupid:
    The error is: Comma without preceding colon (after SELECT ?)
    and this is the code that seems to cause this error:
        LOOP AT i_itm1_c.
          SELECT * FROM /bic/al_itm700 INTO wa_t_data
                    WHERE
                    /bic/al_itm700-/bic/l_docnr
                    LIKE /bic/al_itm1c00-/bic/l_docnr,
                    /bic/al_itm700-bic/l_posnr
                    like /bic/al_itm1c00-/bic/l_posnr,
                    /bic/al_itm700-/bic/yl_kcrdat
                    like /bic/al_itm1c00-/bic/yl_kcrdat,
                    /bic/sourcesys like /bic/al_itm1c00-/bic/sourcesys.
            wa_t_data-recordmode = ''.
           MOVE-CORRESPONDING wa_t_data TO e_t_data.
            MOVE:
            wa_t_data-/bic/l_docnr TO e_t_data-/bic/ydoc_numb,
            wa_t_data-/bic/l_posnr TO e_t_data-/bic/yl_count,
            wa_t_data-/bic/sourcesys TO e_t_data-/bic/sourcesys.
            APPEND e_t_data.
          ENDSELECT.
        ENDLOOP.
    Any ideas on what can be wrong here? points awarded of course!
    thanks!

    remove the commas and use AND or OR and also
    remove like and use = operator
    LOOP AT i_itm1_c.
    SELECT * FROM /bic/al_itm700 INTO wa_t_data
    WHERE
    /bic/al_itm700-/bic/l_docnr
    = /bic/al_itm1c00-/bic/l_docnr <b>and</b> 
    /bic/al_itm700-bic/l_posnr
    = /bic/al_itm1c00-/bic/l_posnr <b>and</b>
    /bic/al_itm700-/bic/yl_kcrdat
    = /bic/al_itm1c00-/bic/yl_kcrdat <b>and</b>
    /bic/sourcesys =/bic/al_itm1c00-/bic/sourcesys.
    wa_t_data-recordmode = ''.
    * MOVE-CORRESPONDING wa_t_data TO e_t_data.
    MOVE:
    wa_t_data-/bic/l_docnr TO e_t_data-/bic/ydoc_numb,
    wa_t_data-/bic/l_posnr TO e_t_data-/bic/yl_count,
    wa_t_data-/bic/sourcesys TO e_t_data-/bic/sourcesys.
    APPEND e_t_data.
    ENDSELECT.
    ENDLOOP.

  • Commit after deleting records

    Hi All,
    I wrote one delete command .This command deletes 20 millions of records.But I want to give "commit" after deleting every 100000 records. How to give "commit" for this requirement.
    please guide me.
    Thank you.

    Depends on your delete statement.
    Sometime you can group the delets into logical units.
    Compare and consider the following three approaches.
    1) This deletes all data from all previous months.Delete from myTable where insertDate < trunc(sysdate,'mm'))
    2) Delete each month separately and commit in between.Delete from myTable where insertDate < trunc(sysdate,'year'));
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),1) -- "january"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),2) -- "February"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),3) -- "March"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    Delete from myTable
    where insertDate >= trunc(sysdate,'year'))
    and insdate < add_months(trunc(sysdate,'year'),12) -- "December"
    and insdate < trunc(sysdate,'mm')) -- do not delete too much!
    commit;
    3) Delete based on ID and logical groups
    Select min(id), max(id) into v_min, v_max
    from myTable where insertDate < trunc(sysdate,'mm'));
    for i in 1..trunc(v_max-v_min)/100000)+1 loop
      delete from myTable
      where id >= v_min+((i-1)*100000)
      and id < v_min+(i*100000)
      and id <= v_max
      and insertDate < trunc(sysdate,'mm')) -- this line is not really needed, maybe remove it depending on the execution plan.
      commit;
    end loop;

  • Commit after 2000 records in update statement but am not using loop

    Hi
    My oracle version is oracle 9i
    I need to commit after every 2000 records.Currently am using the below statement without using the loop.how to do this?
    do i need to use rownum?
    BEGIN
    UPDATE
    (SELECT A.SKU,M.TO_SKU,A.TO_STORE FROM
    RT_TEMP_IN_CARTON A,
    CD_SKU_CONV M
    WHERE
    A.SKU=M.FROM_SKU AND
    A.SKU<>M.TO_SKU AND
    M.APPROVED_FLAG='Y')
    SET SKU = TO_SKU,
         TO_STORE=(SELECT(
              DECODE(TO_STORE,
              5931,'931',
              5935,'935',
              5928,'928',
              5936,'936'))
              FROM
              RT_TEMP_IN_CARTON WHERE TO_STORE IN ('5931','5935','5928','5936'));
    COMMIT;
    end;
    Thanks for your help

    I need to commit after every 2000 recordsWhy?
    Committing every n rows is not recommended....
    Currently am using the below statement without using the loop.how to do this?Use a loop? (not recommended)

  • COMMIT after every 10000 rows

    I'm getting probelms with the following procedure. Is there any that I can do to commit after every 10,000 rows of deletion? Or is there any other alternative! The DBAs are not willing to increase the undo tablespace value!
    create or replace procedure delete_rows(v_days number)
    is
    l_sql_stmt varchar2(32767) := 'DELETE TABLE_NAME WHERE ROWID IN (SELECT ROWID FROM TABLE_NAME W
    where_cond VARCHAR2(32767);
    begin
       where_cond := 'DATE_THRESHOLD < (sysdate - '|| v_days ||' )) ';
       l_sql_stmt := l_sql_stmt ||where_cond;
       IF v_days IS NOT NULL THEN
           EXECUTE IMMEDIATE l_sql_stmt;
       END IF;
    end;I think I can use cursors and for every 10,000 %ROWCOUNT, I can commit, but even before posting the thread, I feel i will get bounces! ;-)
    Please help me out in this!
    Cheers
    Sarma!

    Hello
    In the event that you can't persuede the DBA to configure the database properly, Why not just use rownum?
    SQL> CREATE TABLE dt_test_delete AS SELECT object_id, object_name, last_ddl_time FROM dba_objects;
    Table created.
    SQL>
    SQL> select count(*) from dt_test_delete WHERE last_ddl_time < SYSDATE - 100;
      COUNT(*)
         35726
    SQL>
    SQL> DECLARE
      2
      3     ln_DelSize                      NUMBER := 10000;
      4     ln_DelCount                     NUMBER;
      5
      6  BEGIN
      7
      8     LOOP
      9
    10             DELETE
    11             FROM
    12                     dt_test_delete
    13             WHERE
    14                     last_ddl_time < SYSDATE - 100
    15             AND
    16                     rownum <= ln_DelSize;
    17
    18             ln_DelCount := SQL%ROWCOUNT;
    19
    20             dbms_output.put_line(ln_DelCount);
    21
    22             EXIT WHEN ln_DelCount = 0;
    23
    24             COMMIT;
    25
    26     END LOOP;
    27
    28  END;
    29  /
    10000
    10000
    10000
    5726
    0
    PL/SQL procedure successfully completed.
    SQL>HTH
    David
    Message was edited by:
    david_tyler

  • Commit after n rows while update

    i have 1 update query
    UPDATE security
    SET display_security_alias = CONCAT ('BAD_ALIAS_', display_security_alias)
    WHERE security_id IN (
    SELECT DISTINCT security_id
    FROM security_xref
    WHERE security_alias_type IN ('BADSYMBOL', 'ERRORSYMBOL', 'BADCUSIP', 'ERRORCUSIP' )
    i want to perform commit after every 500rows ( due to Business requirement) how can we achieve this. please help

    J99 wrote:
    As mentioned by karthic_arp --Not a good idea still if you want it you can do this way
    DECLARE
    CURSOR C
    IS
    SELECT DISTINCT security_id
    FROM security_xref
    WHERE security_alias_type IN ('BADSYMBOL', 'ERRORSYMBOL', 'BADCUSIP', 'ERRORCUSIP' );
    -Counter to count records
    counter number(4) default 0;
    BEGIN
    FOR rec in C
    Loop
    UPDATE security SET display_security_alias = CONCAT ('BAD_ALIAS_', display_security_alias)
    WHERE security_id = rec.security_id
    counter := counter +SQL%rowcount ;
    If counter >= 500 then
    counter := 0;
    commit;
    end if;
    END Loop;
    end ;
    /NOT tested.Apart from committing every N rows, being a completely technically stupid idea, committing inside a cursor loop just take it one step further to stupiddom.

  • About procedure to commit after 1000 rows

    i have procedure
    and a cursor c1 is select emp table and
    insert into copy_emp table
    but i want to commit after 1000 record;
    with exception handling
    plz help me with example
    thanks

    Everything you have described is either bad practice in all currently supported versions or bad practice in every version since 7.0.12.
    Cursor loops have been obsolete since version 9.0.1.
    Incremental commiting, for example every 1,000 rows, has always been a bad practice. It slows down processing and manufactures ORA-01555 exceptions.
    For demos of how to properly process data sets look up BULK COLLECT and FORALL at http://tahiti.oracle.com and review the demos in Morgan's Library at www.psoug.org.
    For a long list of good explanations of why you should not do incremental commits read Tom Kyte's many comments at http://asktom.oracle.com.
    Incremental commits may make sense in other products. Oracle is not other products.

  • Need to commit after every 10 000 records inserted ?

    What would be the best way to Commit after every 10 000 records inserted from one table to the other using the following script :
    DECLARE
    l_max_repa_id x_received_p.repa_id%TYPE;
    l_max_rept_id x_received_p_trans.rept_id%TYPE;
    BEGIN
    SELECT MAX (repa_id)
    INTO l_max_repa_id
    FROM x_received_p
    WHERE repa_modifieddate <= ADD_MONTHS (SYSDATE, -6);
    SELECT MAX (rept_id)
    INTO l_max_rept_id
    FROM x_received_p_trans
    WHERE rept_repa_id = l_max_repa_id;
    INSERT INTO x_p_requests_arch
    SELECT *
    FROM x_p_requests
    WHERE pare_repa_id <= l_max_rept_id;
    DELETE FROM x__requests
    WHERE pare_repa_id <= l_max_rept_id;

    1006377 wrote:
    we are moving between 5 and 10 million records from the one table to the other table and it takes forever.
    Please could you provide me with a script just to commit after every x amount of records ? :)I concur with the other responses.
    Committing every N records will slow down the process, not speed it up.
    The fastest way to move your data (and 10 million rows is nothing, we do those sorts of volumes frequently ourselves) is to use a single SQL statement to do an INSERT ... SELECT ... statement (or a CREATE TABLE ... AS SELECT ... statement as appropriate).
    If those SQL statements are running slowly then you need to look at what's causing the performance issue of the SELECT statement, and tackle that issue, which may be a case of simply getting the database statistics up to date, or applying a new index to a table etc. or re-writing the select statement to tackle the query in a different way.
    So, deal with the cause of the performance issue, don't try and fudge your way around it, which will only create further problems.

  • How can I get a list view after selecting "see all"?

    I just updated to iTunes 12.  I've looked on the net for this but couldn't find anything on it.
    Previously when I searched for something in the iTunes store I'd pick a certain category of media (podcasts, for example).  It would give me the first few results and then I could select "see all."  Then get a list view and sort it.
    Now when I click on "see all" I get an album cover view.  NOT a list view.  And I have no way to sort the results.  I usually sort by time.
    What's odd is when I'm still on the initial page you get after making a search I *can* sort the results.  But only the first 10.
    Basically, I need a way to sort all of my search results by time.  Either after selecting "see all" or having iTunes show many more than 10 results.
    This was possible (and the default, I think) in previous versions.  I've looked through every menu and I don't see a way to turn this functionality back on.
    Thanks.

    Hi,
    There is no such PowerShell command can achiev this. Maybe you can use a script to get the user name with folder redirection enabled. However, I am not familiar with writing script, and it would be better for you to ask in script forum below for professional
    assistance:
    http://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG&filter=alltypes&sort=lastpostdesc
    Best Regards,
    Mandy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Data Error in the Query/Report after selective data deletion for infocube

    Hi Experts,
    Please advise what i was missing and what went wrong...
    I got a Query (Forecast) on a Multicube...which is based on 2 Infocubes with Aggregates...
    As i identified some data discrepency..yesteraday i performed selective data deleation on one of the Infocube
    and executed report yesteraday and the results in the query are correct...
    When today i executed the same report i am getting different results..
    When i compared the results of the report with that of data in cube they are not matching
    The report is not displaying the data in cube..for some rows it is displaying the data in the cube but for some rows it is just displaying same as the above row
    there is no data loaded into info cube after selective deleation
    Do i need to perform request compression and fill the aggregated after selective deleation
    Please advise what went wrong

    Hi Venkat,
    No i haven't done anything on aggregates before or after selective delete
    As there is not data load after the selective delete according to SAP Manual we don't need to perform any thing on aggregates...as selective data deletion on cube will delete data from aggregates as well
    Please update how to identify error

  • After download and installation of PS PE12 I have problems starting the programm. After selecting video and new project nothing happens, only the colorbar below new project is showing

    New computer.
    After download and installation of PS PE12
    I have problems starting the programm, double clicking on the icon.
    After selecting video and new project nothing happens, only the colorbar below new project is showing, nothing happens.
    (expected was to activate the program and the sarting the PE12)
    PSE12 runs fine
    System:
    WIN8.1 / i7 /16GB RAM

    New computer.
    After download and installation of PS PE12
    I have problems starting the programm, double clicking on the icon.
    After selecting video and new project nothing happens, only the colorbar below new project is showing, nothing happens.
    (expected was to activate the program and the sarting the PE12)
    PSE12 runs fine
    System:
    WIN8.1 / i7 /16GB RAM

  • "Are you sure you want to shut down your computer?" prompt pops up for no reason and continues to pop up after selecting Cancel. How can I stop this?

    "Are you sure you want to shut down your computer?" prompt pops up for no reason and continues to pop up after selecting Cancel. How can I stop this?
    Mac Pro. OS 10.6.8

    Then I suggest you read this thread regarding the 30" Apple Cinema Display and that particular message pop up... several possible causes... common denominator, the display.
    http://forums.macrumors.com/showthread.php?t=617367

  • LOV is slow after selecting a value its taking much time to default

    Hi,
    I have a dependent LOV. Master LOV is executing fine and its populatin into the field fastly. But Child LOV is very slow after selecting a value its taking much time to default.
    Can any one please help me if there is any way to default the value fast after selecting a value?
    Thanks,
    Mahesh

    Hi Gyan,
    Same issues in TST and PROD instances.
    In my search criteria if i get 1 record, even after selecting that value its taking much time to default that value into the field.
    Please advice. Thanks for your quick resp.
    Thanks,
    Mahesh

Maybe you are looking for

  • I need to do some work in Arabic language...

    Hi I need to do some work in Arabic language... Write text in Arabic language into a food product label I use Google translator for translation But when I copy and paste into illustrator cs4 which I use now Then the Arabic text comes the wrong way Do

  • Is the ipod touch 5th gen going to be available in the 8GB or 16 GB?

    Does anyone know if the Ipod Touch 5th Generation is going to be available in the 8GB or 16GB?

  • HP 1022 networked - only printing within some applicatio​ns

    I can print fine to a networked HP 1022 within Internet Explorer, pdf files and Novell Groupwise messages, but when printing a Word document, excel spreadsheet, Notepad file I get a page of thin horizontal lines covering the entire page. Cannot print

  • CompareTo(Object) is undefined for Object

    I'm getting an error -The method compareTo(Object) is undefined for the type Object- with this code: public static Object getMinimum (Object[] array)    Object min = array[0];    for (int i = 1; i < array.length; i++) {       if (min.compareTo(array)

  • How To Prepare Images For iPhoto Calendar Order...

    I am getting ready to order a calendar through iPhoto '09 and try as I might I have been unable to find the directions on their website as to the specs they want followed in prepping the images. I know I found them last year but I can't find them thi