Re: ALTER TABLE ... REPLACE WITH

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>

From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2010-12-14T19:35:08Z
Lists: pgsql-hackers
On 14.12.2010 20:27, Simon Riggs wrote:
> There are various applications where we want to completely replace the
> contents of a table with new/re-calculated data.
>
> It seems fairly obvious to be able to do this like...
> 1. Prepare new data into "new_table" and build indexes
> 2. Swap old for new
> BEGIN;
> DROP TABLE "old_table";
> ALTER TABLE "new_table" RENAME to "old_table";
> COMMIT;
>
> Step (2) works, but any people queuing to access the table will see
>    ERROR:  could not open relation with OID xxxxx

Could we make that work without error?

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com