From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Shaozhong SHI <shishaozhong@gmail.com>
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: How to explicitly lock and unlock tables in pgsql?
Date: Thu, 17 Mar 2022 08:51:52 +0100
Message-ID: <eed4b6bcda07d197f54a5ea4c1c1194c67778673.camel@cybertec.at> (raw)
In-Reply-To: <CA+i5JwZPLEiOQxFy3q=5HKWYLkfs8VBvHxY03osiW4xy_OoKxw@mail.gmail.com>
References: <CA+i5JwZPLEiOQxFy3q=5HKWYLkfs8VBvHxY03osiW4xy_OoKxw@mail.gmail.com>
On Wed, 2022-03-16 at 20:30 +0000, Shaozhong SHI wrote:
> Table locks present a barrier for progressing queries.
>
> How to explicitly lock and unlock tables in pgsql, so that we can guarantee the progress of running scripts?
You cannot unlock tables except by ending the transaction which took the lock.
The first thing you should do is to make sure that all your database transactions are short.
Also, you should nevr explicitly lock tables. Table locks are taken automatically
by the SQL statements you are executing.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, shishaozhong@gmail.com
Subject: Re: How to explicitly lock and unlock tables in pgsql?
In-Reply-To: <eed4b6bcda07d197f54a5ea4c1c1194c67778673.camel@cybertec.at>
References: <CA+i5JwZPLEiOQxFy3q=5HKWYLkfs8VBvHxY03osiW4xy_OoKxw@mail.gmail.com> <eed4b6bcda07d197f54a5ea4c1c1194c67778673.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox