From: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | Rakesh Kumar <rakeshkumar464(at)outlook(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Autovacuum stuck for hours, blocking queries |
Date: | 2017-02-18 04:32:05 |
Message-ID: | CAOR=d=3sd2myXutOoSEr0D_CevaiLhYGc9++CugzXkU9QA=M3w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Feb 17, 2017 at 1:38 PM, Rakesh Kumar
<rakeshkumar464(at)outlook(dot)com> wrote:
> LOCK TABLE yourtable <a suitable LOCKMODE>;
> CREATE TEMPORARY TABLE keep AS SELECT * FROM yourtable WHERE <keep>;
> TRUNCATE yourtable;
> INSERT INTO yourtable SELECT * from keep;
> COMMIT;
> ===
> the above snippet assumes truncate in PG can be in a transaction. In other words, while truncate by itself
> is atomic, it can't be rolled back. So in the above case, if "INSERT INTO yourtable SELECT * from keep;" and
> we rollback, will it rollback yourtable.
Yes it can. Truncate has been rollbackable for a while now.
begin;
create table
insert into table
truncate old table
. something goes wrong .
rollback;
Unless I misunderstand your meaning.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2017-02-18 07:54:10 | Re: Autovacuum stuck for hours, blocking queries |
Previous Message | Richard Brosnahan | 2017-02-18 02:50:05 | Re: PostgreSQL mirroring from RPM install to RPM install-revisited |