Re: Autovacuum stuck for hours, blocking queries

From: Rakesh Kumar <rakeshkumar464(at)outlook(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Autovacuum stuck for hours, blocking queries
Date: 2017-02-17 20:38:39
Message-ID: BN6PR2201MB15541F974315051F254D08C68C5D0@BN6PR2201MB1554.namprd22.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-02-17 20:56:32 Re: PostgreSQL mirroring from RPM install to RPM install-revisited
Previous Message Richard Brosnahan 2017-02-17 20:34:44 Re: [GENERAL] PostgreSQL mirroring from RPM install to RPM install-revisited