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

From: Kiriakos Georgiou <kg(dot)postgresql(at)olympiakos(dot)com>
To: Andre Lopes <lopes80andre(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to isolate the result of SELECT's?
Date: 2012-03-19 05:47:31
Message-ID: 5AEC04A1-2143-47AF-A15E-3F451D6EAD0A@olympiakos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In all likelihood you do not want to do what you described (lock the tables.) You have to have a basic understanding of MVCC and transaction isolation levels to determine if the default behavior of mvcc + 'read committed' is sufficient. In a lot of cases it is.

Kiriakos

On Mar 18, 2012, at 7:33 PM, Andre Lopes wrote:

> 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?
>
> Best Regards,
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kiriakos Georgiou 2012-03-19 06:09:53 Re: nice'ing the postgres COPY backend process to make pg_dumps run more "softly"
Previous Message Kiriakos Georgiou 2012-03-19 05:24:52 Re: Anonymized database dumps