ODBC 10.2 client makes SELECT FOR UPDATE run slower

Hi all,
I'm facing a strange problem with Oracle OBDC: I got an application which needs to connect to an Oracle DB via odbc.
Server is a 10.2.0.1; if I connect using ODBC driver installed by Oracle 8 client everything is ok but if I use ODBC driver installed by Oracle 10 client or Oracle XE client SELECT FOR UPDATE statements become really slower.
My application always does the same statement:
SELECT list_of_fields
FROM table
WHERE primary_key =
AND ...
FOR UPDATE;
If I use the Oracle 8 ODBC, this select is almost immediate; but if I use Oracle 10 ODBC it tooks ~4 seconds.
The statement is identical, so the access plan must be the same.
The ODBC configuration is identical too; tnsnames.ora entries are the same.
So, why the 10x clients are slower?
thanks for every answer
andrea
Message was edited by:
user585511
Message was edited by:
user585511

Which cursor library are you using? The ODBC Driver Manager's cursor library strips off the FOR UPDATE silently (see Appendix F of the ODBC Programmer's Reference). Depending on what version of the "Oracle 8 client" you were using, there may not have been an ODBC driver cursor library, so you may have been forced to use the driver manager's. Potentially, the slowdown is that you're now actually locking the rows now and may be running some contention issues.
It would be worthwhile to trace the sessions and see what the difference in waits is.
Justin

Similar Messages

  • Should i use SELECT for update NOWAIT ?

    Hi:
    Do I need to use, in my pl/sql triggers and procedures, the SELECT FOR UPDATE NOWAIT sentence, to avoid locks before using update table sentences ? Is it common to use it on stored procedures and triggers?
    Thanks
    Joao Oliveira

    First, what, exactly do you mean by "avoid locks"? I was interpreting that to mean "I want to avoid creating locks in my session that might block someone else", not "I want to avoid having my SELECT wait for locks to be released-- I want it to fail immediately". If you meant the latter, then SELECT ... FOR UPDATE NOWAIT would be what you want. If you meant the former, then pessimistic locking is not what you want.
    Second, what sort of Oracle Forms architecture do you have? Are you still using old-school client-server applications? Or are you using a three-tiered approach? As Tom discusses in that thread, pessimistic locking is only an option when your client application is able to maintain database state across calls (i.e. client/server systems) not when you have stateless connections (which is the norm in the three-tier model). The old client-server versions of Forms would automatically and transparently do pessimistic locking. Since you didn't mention anything about your architecture, most of us probably assumed the more common stateless client architecture (note how Tom's answers progress over the 5 years in that thread as client/server architecture became less and less common).
    Third, while your question is appropriate for either the Database - General forum or the SQL and PL/SQL forum, that generally means that you are free to post it either forum, not that it should be posted in both. The vast majority of the folks that hang out in one forum hang out in the other. It's also rather frustrating to answer a post in one forum only to discover that there is another post in a different forum where someone else had already covered the same points half an hour earlier or to discover that there was additional information in another thread that might have changed your answer.
    Fourth, if you are going to do pessimistic locking, that requires that you are able to maintain state across various database calls, that you are locking on the lowest possible level of granularity, and that you are able to time out sessions relatively aggressively to ensure that someone doesn't open a record, thereby locking it, go to lunch (or have their system die) and then block everyone else from working. Assuming that is the case, and that you have some reasonable way to handle the error that gets generated other than simply retrying the operation, adding NOWAIT is certainly an option. Most applications, particularly those getting written today, cannot guarantee all these things, so pessimistic locking is generally not appropriate there.
    Looking at your other thread (where there is new information that would be useful in this discussion, one of the reasons that multiple threads are generally a bad idea), it seems that you have an ERP application and you are concerned about the performance of entering orders. Obviously, there shouldn't be any locking issues on the ORDER or ORDER_DETAILS tables, assuming that multiple users aren't going to be inserting the same order at the same time. The contention would almost certainly come when multiple orders are trying to update the STOCK and INVENTORY tables, since multiple orders presumably rely on the same rows in those tables. In that case, I'm not sure what adding a NOWAIT would buy you-- unless you were going to roll back the entire order because someone is updating the STOCK row for #2 pencils and your order has an item of #2 pencils, you'd have to keep retrying the operation until you were able to modify the STOCK row, which would be less efficient than just letting that update block until the row was free.
    Now, you could certainly redesign the application to minimize that contention by not trying to update what I assume are aggregate tables like STOCK and INVENTORY directly as part of your OLTP processing or, at least, by minimizing the time that you're locking a row. You could, for example, make STOCK and INVENTORY materialized views rather than tables that refresh ON COMMIT, which should decrease the time that your locks are held. You could also have those tables refreshed asynchronously, which would be even more efficient but may require that you reasses your holdback requirements.
    Justin

  • Difference in select for update of - in Oracle Database 10g and 11g

    Hi, I found out that Oracle Database 10g and 11g treat the following PL/SQL block differently (I am using scott schema for convenience):
    DECLARE
      v_ename bonus.ename%TYPE;
    BEGIN
      SELECT b.ename
        INTO v_ename
        FROM bonus b
        JOIN emp e ON b.ename = e.ename
        JOIN dept d ON d.deptno = e.deptno
       WHERE b.ename = 'Scott'
         FOR UPDATE OF b.ename;
    END;
    /While in 10g (10.2) this code ends successfully (well NO_DATA_FOUND exception is raised but that is expected), in 11g (11.2) it raises exception "column ambiguously defined". And that is definitely not expected. It seems like it does not take into account table alias because I found out that when I change the column in FOR UPDATE OF e.empno (also does not work) to e.mgr (which is unique) it starts working. So is this some error in 11g? Any thoughts?
    Edited by: Libor Nenadál on 29.4.2010 21:46
    It seems that my question was answered here - http://stackoverflow.com/questions/2736426/difference-in-select-for-update-of-in-oracle-database-10g-and-11g

    The behaviour seems like it really is a bug and can be avoided using non-ANSI syntax. (It makes me wonder why Oracle maintains two query languages while dumb me thinks that this is just a preprocessor matter and query engine could be the same).

  • Lock Cascade With Select for UPDATE

    If I had a employee table and a phone table with a parent/child relationship and a primary key constraint on the employee table-will issuing a select for update on the employee also lock the corresponding child rows on the phone table ?
    If not how can I bring this about ?

    You only need two sessions:
    First session: Issue the 'select for update'
    statements for the row(s) in both tables, don't
    rollback or commit
    Second session: try to update a row that you tried to
    lock in the first session (with NOWAIT).
    Thanks. I can try this definitely. A basic question.
    You are asking me to do a join on both the tables right ?
    Not two individual SQL statements ?
    Updating the primary key is known as a Bad Idea (tm).
    The key should never be touched because it should be
    meaningless. When you have a column that holds 'real'
    information it is no candidate for a primary key.
    Rgds,
    GuidoYes I am aware of that. I was just wondering what is the meaning behind this statement from this link ?
    http://www.akadia.com/services/ora_locks_survival_guide.html
    And the exact phrase from that link under the section Referential Integrity Locks (RI Locks)
    "RI constraints are validated by the database via a simple SELECT from the dependent (parent) table in question-very simple, very straightforward. If a row is deleted or a primary key is modified within the parent table, all associated child tables need to be scanned to make sure no orphaned records will result. "
    Thanks again.

  • Pros and  cons  of  select  for  update  clause

    hi,
    Can anybody explain what are the
    pros and cons of select for update clause
    11.2.0.1

    As commented, there are no pros versus cons in this case.
    What is important is to understand conceptually what this do and why it would be use.
    Conceptually, a select for update reads and locks row(s). It is known as pessimistic locking.
    Why would you want to do that? Well, you have a fat client (Delphi for example) and multiple users. When userA updates an invoice, you want that invoice row(s) locked and prevent others from making updates at the same time. Without locking, multiple users updating the same invoice will result in existing updated data being overwritten by old data that also has been updated. A situation called lost updates.
    For web based clients that are stateless, pessimistic locking does not work - as the clients do not have state and pessimistic locking requires state. Which means an alternative method to select for update needs to be used to prevent lost updates. This method is called optimistic locking.
    So it is not about pros versus cons. It is about understanding how the feature/technique/approach works and when to use it.. and when it is not suited to use it. All problems are not nails. All solutions are not the large hammer for driving in nails.

  • Clarification on SELECT for UPDATE

    HI All,
    I am doing a SELECT FOR UPDATE using NOWAIT as well as SKIPLOCKED option. I have question regarding the general behavior.
    Suppose let say , I have two tables (table1 and table 2 ).
    TABLE 1
    header_id NUMBER,
    service_id NUMBER
    TABLE 2
    header_id NUMBER,
    line_id NUMBER,
    status VARCHAR2
    And I run the following query
    SELECT t2.header_id, t2.line_id
    FROM table1 t1, table2 t2
    WHERE t1.header_id = t2.header_id
    AND t1.service_id = 1
    AND t2.status = 'SUCCESS'
    FOR UPDATE OF t2.status NOWAIT SKIP LOCKED;
    Questions
    1) Does adding both the NOWAIT and SKIP LOCKED in the sql help or just SKIP LOCKED would do fine.
    2) Lets say this SQL is executed when there are no rows with status as 'SUCCESS' in table2. Would this cause any performance impact. Like for example since its joining with table1 with table 2 based on the header id .Would it lock any rows on table1?
    ( My understanding was that it would not lock any row until it finds out any row with status as 'SUCCESS' but getting some conflicting answers)
    Thanks,
    Vj

    AKVK wrote:
    ( My understanding was that it would not lock any row until it finds out any row with status as 'SUCCESS' but getting some conflicting answers)THis would be my understanding too.
    To be sure make a test.
    Do the select for update so that it does not lock any rows.
    Then check the data dictionary select * from v$lock; to see for your session if there are any locks.

  • SELECT FOR UPDATE - does it write to REDO?

    Greetings folks,
    we have some strange performance issues with a recent application update. This is custom in-house application. Every morning since the deploy we get a spike in load, especially to log sync / redo archive. We capture activity surrounding the load, and found many "select for update" statements.
    Im digging through metalink and docs looking to confirm "write or no write" to the redo log files. comments appreciated.

    sb92075 wrote:
    SELECT does not generate REDO
    DML generates REDO.It is possible for a SELECT to generate redo due to the effects of delayed block cleanout. A small test case:
    Session 1:
    CREATE TABLE T10 AS
    SELECT
      ROWNUM RN
    FROM
      DUAL
    CONNECT BY
      LEVEL<=1000;
    UPDATE
      T10
    SET
      RN=RN;
    UPDATE
      T10
    SET
      RN=RN;
    UPDATE
      T10
    SET
      RN=RN;
    Session 2:
    ALTER SYSTEM FLUSH BUFFER_CACHE;
    ALTER SYSTEM FLUSH BUFFER_CACHE;
    Session 1:
    COMMIT;
    Session 2:
    SET AUTOTRACE ON STATISTICS
    SELECT
    FROM
      T10;
    1000 rows selected.
    Statistics
              0  recursive calls
              0  db block gets
             73  consistent gets
              3  physical reads
            188  redo size
          11104  bytes sent via SQL*Net to client
           1060  bytes received via SQL*Net from client
             68  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           1000  rows processedNote that the above may be performed in a single session rather than using two sessions. Essentially, the flush of the buffer cache causes the dirty blocks (containing uncommitted changes) to be written to disk, and the blocks are "cleaned up" during the next SELECT which accesses the blocks.
    A much better explanation:
    http://jonathanlewis.wordpress.com/2009/06/16/clean-it-up/
    Charles Hooper
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • SELECT FOR UPDATE via KODO queries

    I want to do the following in a transaction:
    1) SELECT * from Foo where type='x' FOR UPDATE
    2) UPDATE Foo set sequence='22' where type='x'
    3) commit
    The issue: is there any way to force KODO to add the 'for update' in a find query.
    Thanks

    Please try kodo.LockManager configuration property.
    -pessimistic: This is an alias for the kodo.jdbc.kernel.PessimisticLockManager , which uses SELECT FOR UPDATE statements (or the database's equivalent) to lock the database rows corresponding to locked objects. This lock manager does not distinguish between read locks and write locks; all locks are write locks.
    Also please make sure you have following setting
    kodo.jdbc.DBDictionary: SupportsSelectForUpdate=true
    Please check kodo doc section 9.4.4.
    JPA looks like
    <property name="kodo.LockManager" value="pessimistic(VersionCheckOnReadLock=true,VersionUpdateOnWriteLock=true)"/>
    JDO looks like
    kodo.LockManager: pessimistic(VersionCheckOnReadLock=true,VersionUpdateOnWriteLock=true)
    Thanks,
    Yun

  • Select for update on stateless connections

    i have read that using select for update for a web application will not work specially if the stateless connection are used , and the best way to make sure that the column you are reading was not changed is to use the time stamp approach and not select for update?? i am right

    Not entirely correct.
    A connection/session to Oracle has state. There is no such thing as a stateless Oracle connection.
    The stateless connection is from the web browser to the web server. It makes a connection. Asks for a page (GET, PUT or POST typically). It gets a response from the web server. It closes that connection.
    When the web server response, it opens a (stateful) connection to Oracle. Or it re-uses an existing (stateful) Oracle connection (now idle after having serviced another web browser/web server request).
    The problem with pessimistic locking (e.g. SELECT FOR UPDATE) is that the very same (stateful) Oracle session will either
    a) be closed when a response is send to the web browser
    b) be used for another totally different web browser
    Thus any locks made will either be lost (option a) or will get used by the wrong web browser (option b).
    A method is therefore needed to make the lock spans different Oracle (stateful) sessions. Web browser selects rows to update using Oracle session 101 at Time 1. Web browser submits updated rows and a commit using Oracle session 142 at Time 2.
    The "best way" to handle optimistic locking is likely using the Oracle System Change Number (SCN). This represents the "current version" of the rows.
    So at Time 1, via Session 101, you give the web browser a 100 rows to update - together with the SCN that says the current version of the rows are v1.2.0.1.
    At Time 2, using Session 142, the web browser submits its changes for those 100 rows. Together with the SCN v1.2.0.1.
    The SQL UPDATE issues the update statement - but adds the SCN version criteria. If the UPDATE fails to update all 100 rows, it means that some of the rows no longer exist, or that some rows have a new version number (was changed in the meantime).
    In this case, the UPDATE is rolled back and an exception raised to tell the web browser that some (or all) of those 100 rows have been changed in the meantime.
    Refer to the [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns007.htm#BABFAFIC]Oracle® Database SQL Reference for details.

  • How to SELECT FOR UPDATE with CMP (Oracle)

    The most common database (Oracle) by default uses a scheme that does not fit into any of those isolation levels. A SELECT statement selects data at the start of the transactions, whereas a SELECT ... FOR UPDATE does something quite different. It is essential to do SELECT FOR UPDATEs before updating the row as SELECT does no lock. It's a hack that works well in practice.
    1. Which isolation level is this?
    2. More fundamentally, how an earth is it possible to use this scheme with CMP?! You would have to distinguish load() from loadForUpdate()! Is CMP inconsistent with Oracle?
    This is a pretty big whole in the CMP spec!

    No. thats no goes well.
    Transaction serializable in Oracle uses a optimistic
    concurrency system. And for update is a
    pessimistic concurrency.
    With optimistic: the system is faster but it can fail
    With pessimistic: if doesnt fail (usually;)
    You can solve the proble with many differents systems:
    1. Edit the .xml descriptor files ans change the sql sentences.
    And my prefer one.
    2. Make a new jdbc driver that inherits from the original
    oracledriver.
    The new driver give u in "getConnection()" a new connection class that inherits from the original connection.
    The executestatement and preparestatement adds the
    string "for update" if the stattement was starting by select.
    Configure your container to use the new driver.

  • When does select for update release locks

    Hello all,
    Does anyone know when Oracle realeases the row locks when a
    select for update is issued?
    Does Oracle realase the row lock at the time when an actual update statement is
    issued for the locked row, or does it wait until a commit statment is executed?
    So for example, can I lock several rows with a select for update clause, and then
    issue update statements as many times as I want on each locked row without
    having to worry about the lock being released until I issue a commit statement.
    Thanks,
    David

    yes.
    The lock is released only when your transaction ends. A transaction can end because of:
    1). Commit.
    2). Rollback.
    3). client disconnects.
    etc. etc...

  • Memory Leak - select for update

    Hi All.
    Doing an application using OCI 8.1.7 I faced with a memory leak. (or it seems to). The leak is caused by OCIStmtExecute with SELECT FOR UPDATE statement when the iters parameter of that function is 0. In all other cases it works Ok. Below you can find a code causes a leak:
    const char* sqlStatement = "select integercol from test_types for update";
    OCIStmt* ociStatementHandle = 0;
    OCIHandleAlloc(ociEnvHandle,(dvoid **)&ociStatementHandle,
    OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
    OCIStmtPrepare(ociStatementHandle, ociErrorHandle,
    (text*)sqlStatement, strlen(sqlStatement), OCI_NTV_SYNTAX, OCI_DEFAULT));
    int int_test;
    OCIDefine* ociDefineHandle = 0;
    OCIDefineByPos(ociStatementHandle, &ociDefineHandle, ociErrorHandle,
    1, (dvoid *)&int_test, (sword) sizeof(int), SQLT_INT, (dvoid *) 0, (ub2 *)0,
    (ub2 *)0, OCI_DEFAULT));
    ub4 iters = 0; // (0 causes a leak)
    for( int i=0; i < 100000; i++ )
    OCIStmtExecute(ociServiceHandle, ociStatementHandle, ociErrorHandle, iters, (ub4) 0, (CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT));
    If I change iter to 1 the leak disappears, but it is not suitable of course. Oracle documentation says following:
    iters (IN)
    For non-SELECT statements, the number of times this statement is executed is equal to iters - rowoff.
    For SELECT statements, if iters is non-zero, then defines must have been done for the statement handle. The execution fetches iters rows into these predefined buffers and prefetches more rows depending upon the prefetch row count. If you do not know how many rows the SELECT statement will retrieve, set iters to zero.
    This function returns an error if iters=0 for non-SELECT statements.
    Did somebody face the problem? Do you know how to fix it?
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Bjorn Engsig ([email protected]):
    Are you saying, that the memory leak disappears if you don't do 'for update' in the query?
    Also, is the memory leak on the client or server side?<HR></BLOCKQUOTE>
    Yes, the leak appeares ONLY for 'select ... for update' statements.
    It is a client side leak, the client is Win2000.
    null

  • How to avoid 'select for update'

    Hi,
    we are using the bc4j framework of jdev 3.2.3. We have a View which collects data from several tables in different database schemes, so we naturally have to use the 'union clause'. But if we try to make an update on a row (via 'setAttribute'), we got a DMLException ORA-02014 telling us that we should not use 'select for update' on views whith unions.
    Since i cannot avoid using a union clause, is there a way to avoid the 'select for update' in the bc4j framework?
    Please help, its urgent!
    Thanx,
    Dietmar

    SELECT FOR UPDATE is used for our implementation or row-level locking.
    If you are using pessimistic locking mode, this will occur the first time any attribute is modified.
    If you are using optimistic locking mode, it will be deferred until post/commit time.
    If you are using "none" locking mode, it will not happen in your application may hang indefinitely if another session has locked the row.
    Are you asking how to avoid locking?
    Do you mean to be updating this view with a union over multiple databases?

  • Error message: "playlists selected for updating no longer exist"

    I tried to update my ipod nano and I guess I had deleted a playlist, but since then, I have not been able to update. Every time I try, I get the following message:
    "Cannot be updated because all of the playlists selected for updating no longer exist."
    I haven't been able to highlight which playlists are selected to begin with.
    I read through the manual and thought that maybe rebooting the whole system might work. So I deleted Itunes from my computer and re-installed.
    Then I tried re-setting my ipod. So now I have nothing on my ipod.
    I also deleted everything from my library, thinking it might help to start from scratch. Nothing has worked.
    How do I "select" and "unselect" playlists so I can get up and running again?

    Here you go.
    http://discussions.apple.com/thread.jspa?messageID=607312&#607312

  • Lost music on ipod because "playlists selected for updating no longer exist

    Not sure what I've done. I recently downloaded newer version of itunes. Then when synching, I had too much music in my library for the ipod to handle so it told me about doing the smart playlist. I erased a couple of playlists on the itunes menu I no longer wanted and then when I went to synch, this error came up "songs on the ipod cannot be updated because all of the playlists selected for updating no longer exist."
    Please help.....

    Check this out.
    iPod cannot sync because one or more playlist....

Maybe you are looking for

  • Installed 10.8.4 and now my wifi refuses to connect to any WPA2 network!

    Installed 10.8.4 update yesterday in the office. After restart my wifi refused to connect to the network although it was connecting to it fine before the update. Used ethernet and downloaded the Combo update. No improvement. It connects to the public

  • Stear Clear of MOTU Symphonic instrument!!!

    Was well pleased to be given a version of this software (at first!) - unfortunetley apart from having a nightmare getting my external hard-drive to except the samples DVD, the actual instrument totally screwed up Logic! After installing, it crashed,

  • Button Not Working

    I have a flash page entering into the welcome page of Dreamweaver. In flash I have a button Enter Site, my script is on (release) { getURL(" http://wiweddingconnection.com/welcome.html"); Keep getting this error message Mouse events are permitted onl

  • Can't sync photos! :-(

    Okily... I've recently bought a 30GB video iPod and everything was all going fine until I tried to put photos on it. When I try to sync photos to my iPod I get the message "The iPod cannot be synced. The required file cannot be found." Any help great

  • License issue on multiple ip machine with WLServer6.0

    We are running weblogic 6.0 sp2 on solaris with the machine having multiple ip addresses. The primary address of the machine is 10.4.0.62 and ip address of one of the interfaces is 10.5.2.2. We want to run weblogic through 10.5.2.2 ip address and hav