Avoid Dirty Reads

  • I have a transaction:

    BEGIN

    TRAN

    SELECT

    * FROM dbo.PKSETUP WITH (SERIALIZABLE, XLOCK)--(XLOCK, ROWLOCK) WHERE FILE_NAME = RTRIM('MTREME01.DBF') AND FIELD_NAME = RTRIM('CRECENO')

    -- Add 5 sec sleep to widen the window for the deadlock

    WAITFOR

    DELAY '00:00:15'

    COMMIT

    TRANSACTION

     

    And I want avoid reads from other transaction:

    SELECT

    * FROM dbo.PKSETUP WHERE FILE_NAME = RTRIM('MTREME01.DBF') AND FIELD_NAME = RTRIM('CRECENO')

    But at the same time could be readed other row in this same table:

    SELECT

    * FROM dbo.PKSETUP WHERE FILE_NAME = RTRIM('ACARCASH.DBF') AND FIELD_NAME = RTRIM('CTRNNO')

    The Delay Time is just to evaluation purposes.

    The PK in this Table is FILE_NAME AND FIELD_NAME

    Thanks for your help

  • Make sure you have an index in

    FILE_NAME  and  FIELD_NAME

     


    * Noel

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply