Re: Please help me understand unlogged tables - Mailing list pgsql-general

From Jeff Janes
Subject Re: Please help me understand unlogged tables
Date
Msg-id CAMkU=1zw1_PWL-P7kaCBeC8ePGCvQTjPDZ=8O5y8Awb7qm_nMA@mail.gmail.com
Whole thread Raw
In response to Please help me understand unlogged tables  (Alexander Stoddard <alexander.stoddard@gmail.com>)
List pgsql-general
On Wed, Jan 31, 2018 at 8:52 AM, Alexander Stoddard <alexander.stoddard@gmail.com> wrote:
If a table is set to unlogged is it inherently non-durable? That, is any crash or unsafe shutdown _must_ result in truncation upon recovery?

Yes.
 
I can imagine a table that is bulk loaded in a warehousing scenario and then sitting statically could be safe, but maybe the question becomes how could the system know it is unchanged if it isn't logged...

Right, that is the problem.  It would be nice to solve it, but there are no immediate plans that I know of to implement that.  It is hard, because during recovery the system can't query system catalog tables to get information out of them.  That is why unlogged tables are indicate by the existence of certain files in the filesystem, so the system can know they are unlogged without querying the system catalogs to find out.
 
Would a correct solution be to bulk load into an unlogged table and then (fairly cheaply?) set the table back to being logged?

Unfortunately, it is not cheap for large tables.

I have some large datasets which I could always regenerate if needed, which I don't want blowing out my wal archive.  I've resigned myself to just reloading them after a crash (or after using pg_basebackup to reclone production to make a fresh test/dev server).  If the ETL step from the raw source is expensive, then I \copy the table out to a file, and then \copy it back in after a crash, to save on the ET time.
  

Cheers,

Jeff

pgsql-general by date:

Previous
From: Michał Muskała
Date:
Subject: Unexpected ErrorMessage reply to SSLRequest
Next
From: Michael Paquier
Date:
Subject: Re: Please help me understand unlogged tables