From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Willy-Bas Loos" <willybas(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: using DROP in a transaction |
Date: | 2008-02-08 00:06:50 |
Message-ID: | 18877.1202429210@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Willy-Bas Loos" <willybas(at)gmail(dot)com> writes:
> then in TTY2, run
> begin;
> drop table test;
> create table test (id int4 primary key);
> insert into test (id) values (2);
> then, in TTY1:
> select * from test;
> Actually, i thought of a longer test, but it stops here - there is no
> response, no prompt anaymore, until i cancel the query.
DROP TABLE takes an exclusive lock. The SELECT is waiting for that
lock to be released.
You could shorten the length of the exclusive lock by creating and
filling the replacement table under a new name, then DROP, then
rename the new table into place and immediately commit. But you
aren't going to be able to eliminate it entirely.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | SunWuKung | 2008-02-08 00:20:20 | Re: "advanced" database design (long) |
Previous Message | Willy-Bas Loos | 2008-02-07 23:58:16 | Re: using DROP in a transaction |