Results 1 to 6 of 6

Thread: Read locks ?

  1. #1
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200

    Unanswered: Read locks ?

    Hai all,

    Does Db2 tables have read locks when they are being selected.Sql Server has a kind of lock called read lock which is held when it is selected.

    I would like to know if there is any such read locks,if so is there any way to avoid read locks ,when the table is being selected.

    Thnks in advance

    micky

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: Read locks ?

    Yes, they are commonly called Share Locks(S-Locks) ... There are a few types of share locks ...

    You can avoid taking these locks using Uncommitted Read(UR) ... But this could mean a wrong resultset (as the name suggests, uncommited rows are read) ....

    Locks are there for a purpose and so it does not make sense avoiding it (unless your application is tolerant) ...

    Have a look at your SQL query and tune it , add indexes, meaning a smller result set and inturn no lock escalation ....

    Cheers

    Sathyaram

    Originally posted by mickykt
    Hai all,

    Does Db2 tables have read locks when they are being selected.Sql Server has a kind of lock called read lock which is held when it is selected.

    I would like to know if there is any such read locks,if so is there any way to avoid read locks ,when the table is being selected.

    Thnks in advance

    micky

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Another way to avoid locking is to use the "FOR READ ONLY"
    clause on all selects that are only looking at data with no intention for changing it.

    Andy

  4. #4
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200
    Hai,

    Thanks for the help.Is this to be done in the application level.Can we modify it in the application level.

    Regards,
    micky

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Micky,
    Yes, wherever you submit a SELECT that is only intended to look at the data, add the "FOR READ ONLY" clause. This means modifying the application where this is done.

    Example:
    what you currently have:
    SELECT * from MyTable where (column1 = somevalue)
    change it to:
    SELECT * from MyTable where (column1 = somevalue) FOR READ ONLY

    HTH

    Andy

    Originally posted by mickykt
    Hai,

    Thanks for the help.Is this to be done in the application level.Can we modify it in the application level.

    Regards,
    micky

  6. #6
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200
    Hai
    THank you very much for your support and help.

    Regards,

    micky

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •