Re: [GENERAL] Autovacuum stuck for hours, blocking queries - Mailing list pgsql-general

From Scott Marlowe
Subject Re: [GENERAL] Autovacuum stuck for hours, blocking queries
Date
Msg-id CAOR=d=3sd2myXutOoSEr0D_CevaiLhYGc9++CugzXkU9QA=M3w@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Autovacuum stuck for hours, blocking queries  (Rakesh Kumar <rakeshkumar464@outlook.com>)
Responses Re: [GENERAL] Autovacuum stuck for hours, blocking queries  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-general
On Fri, Feb 17, 2017 at 1:38 PM, Rakesh Kumar
<rakeshkumar464@outlook.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.


pgsql-general by date:

Previous
From: Richard Brosnahan
Date:
Subject: Re: [GENERAL] PostgreSQL mirroring from RPM install to RPMinstall-revisited
Next
From: Michael Paquier
Date:
Subject: Re: [GENERAL] Autovacuum stuck for hours, blocking queries