Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Unanswered: "FOR READ ONLY" to increase performance?

    Hi!

    I use JDBC - prepared statements to retrieve rows from a DB2-table.
    The resulting rows are then displayed on a webpage, but no update is made on them.

    Should I use the 'FOR READ ONLY' - clause in the select statement?
    Does this have a positive effect on the performance or locking?
    (the isolation level is set to cursor stability)

    Thank you for your help!

    Andreas

  2. #2
    Join Date
    Aug 2003
    Posts
    16

    Re: "FOR READ ONLY" to increase performance?

    [QUOTE][SIZE=1]Originally posted by Trollo
    Hi!

    I use JDBC - prepared statements to retrieve rows from a DB2-table.
    The resulting rows are then displayed on a webpage, but no update is made on them.

    Should I use the 'FOR READ ONLY' - clause in the select statement?
    Does this have a positive effect on the performance or locking?
    (the isolation level is set to cursor stability)

    Hi!

    How did you set the isolation level to cursor stability?
    I mean, which of the following JDBC isolation levels corresponds to it: TRANSACTION_READ_COMMITTED,
    TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPETABLE_READ,
    TRANSACTION_SERIALIZABLE ?

    Mona

  3. #3
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    37
    It is not necessary.

    1)
    The FOR READ ONLY clause makes an awful lot of sense when you need to declare a cursor and you want it not be ambiguous. Ambiguous cursors (when DB2 cannot determine up front what your intention with the resource will be; i.e., will you also be performing updates from the same cursor or only selects).

    As JDBC isolates the client-side code from actual cursor handling (done through the ResultSet object), the FOR READ ONLY clause will not take effect.

    2)
    With the DB2 Universal JDBC Driver, you can make a connection read-only through the readOnly property for a Connection or DataSource object.

    The DB2 JDBC Type 2 Driver uses the Connection.setReadOnly value when it determines whether to make a connection read-only. However, setting Connection.setReadOnly(true) does not guarantee that the connection is read-only. Go figure!

    3)
    Of course, if you are using stored procedures that are being called from JDBC (CallableStatement) and that use cursors, then it will start to make sense to include FOR READ ONLY.

    HTH

    Julius

  4. #4
    Join Date
    Mar 2004
    Posts
    3

    Re: "FOR READ ONLY" to increase performance?

    Originally posted by b_moni
    Hi!

    How did you set the isolation level to cursor stability?
    I mean, which of the following JDBC isolation levels corresponds to it: TRANSACTION_READ_COMMITTED,
    TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPETABLE_READ,
    TRANSACTION_SERIALIZABLE ?

    Mona
    Hi Mona!

    To set the isolation level to cursor stability you have to use TRANSACTION_READ_COMMITED in the JDBC connection object.

    Andreas

  5. #5
    Join Date
    Mar 2004
    Posts
    3
    Hi jsasvari!

    Thank you for your answer & the explaination!

    Andreas

Posting Permissions

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