Re: How to isolate the result of SELECT's?

From: Jayadevan M <Jayadevan(dot)Maymala(at)ibsplc(dot)com>
To: Andre Lopes <lopes80andre(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>, pgsql-general-owner(at)postgresql(dot)org
Subject: Re: How to isolate the result of SELECT's?
Date: 2012-03-19 03:39:40
Message-ID: OF76C71835.458B359E-ON652579C6.0013AAD3-652579C6.00141CE0@ibsplc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
>
> I need to do an operation that I will use some SELECT's and get the
> results, but I want to have sure that those tables have not been
> changed with INSERT's or UPDATES during the operation.
>
> Example:
>
> BEGIN OPERATION
> Select field from table1;
> ...
> Select other_field from table2;
> ...
> END OPERATION
>
> How can I lock these tables to assure that the tables are not getting
> INSERTS's or UPDATE's during the operation?
>
If you set transaction isolation level to repeatable, the tables may
undergo changes, but you will get repeatable reads. Explicitly locking the
tables is another option.
http://www.postgresql.org/docs/current/static/explicit-locking.html
Regards,
Jayadevan

DISCLAIMER:

"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Aleksey Tsalolikhin 2012-03-19 04:06:02 nice'ing the postgres COPY backend process to make pg_dumps run more "softly"
Previous Message Doug Gorley 2012-03-19 01:22:03 Re: Zero-length character breaking query?