Information regarding Table-Locks

Started by sri harshaabout 11 years ago4 messagesgeneral
Jump to latest
#1sri harsha
sriharsha9992@gmail.com

Hi,

I have a few doubts regarding table locks. Assume I am executing the
following query

Query 1 -- INSERT INTO FOREIGN_TABLE SELECT * FROM POSTGRES_TABLE

Query 2 -- INSERT INTO FOREIGN_TABLE SELECT * FROM FOREIGN_TABLE

If i get a table lock for the foreign table , will the second table from
which i am getting the data will also come under this lock ?? Or is it a
separate lock ?? Does postgres handle that lock ??

What kind of lock will the second table will be in ?? Can i rename the
second table while executing the INSERT QUERY ??

Thanks,
Harsha

#2John R Pierce
pierce@hogranch.com
In reply to: sri harsha (#1)
Re: Information regarding Table-Locks

On 1/15/2015 9:14 PM, sri harsha wrote:

What kind of lock will the second table will be in ?

I suspect that depends on what FOREIGN_TABLE is connected to.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3sri harsha
sriharsha9992@gmail.com
In reply to: John R Pierce (#2)
Re: Information regarding Table-Locks

Hi John.

What if my query was INSERT INTO Postgres_Table_A SELECT * FROM
Postgres_Table_B ?? What are the locks given for the two tables ??

--Harsha

On Fri, Jan 16, 2015 at 10:50 AM, John R Pierce <pierce@hogranch.com> wrote:

Show quoted text

On 1/15/2015 9:14 PM, sri harsha wrote:

What kind of lock will the second table will be in ?

I suspect that depends on what FOREIGN_TABLE is connected to.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Guillaume Lelarge
guillaume@lelarge.info
In reply to: sri harsha (#3)
Re: Information regarding Table-Locks

Le 16 janv. 2015 06:27, "sri harsha" <sriharsha9992@gmail.com> a écrit :

Hi John.

What if my query was INSERT INTO Postgres_Table_A SELECT * FROM

Postgres_Table_B ?? What are the locks given for the two tables ??

If they are both regular tables, they can insert at the same time. But you
can't rename a take while it's being read or written.

--Harsha

On Fri, Jan 16, 2015 at 10:50 AM, John R Pierce <pierce@hogranch.com>

wrote:

Show quoted text

On 1/15/2015 9:14 PM, sri harsha wrote:

What kind of lock will the second table will be in ?

I suspect that depends on what FOREIGN_TABLE is connected to.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general