Re: unlogged tables

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
Cc: dgabriel <gabriel(dot)dodan(at)gmail(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: unlogged tables
Date: 2015-04-13 20:58:43
Message-ID: 552C2E03.5060800@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 4/13/15 3:49 PM, David G. Johnston wrote:
> On Monday, April 13, 2015, Matheus de Oliveira
> <matioli(dot)matheus(at)gmail(dot)com <mailto:matioli(dot)matheus(at)gmail(dot)com>> wrote:
> On Mon, Apr 13, 2015 at 4:31 PM, dgabriel <gabriel(dot)dodan(at)gmail(dot)com
> <javascript:_e(%7B%7D,'cvml','gabriel(dot)dodan(at)gmail(dot)com');>> wrote:
>
> "In the event of a normal shutdown, we can flush all the writes
> to disk
> so we know all the data has been written, so there is no need to
> truncate."
>
> Isn't possible to periodically flush data to disk and in case of
> crush
> postgres to load only the data that existed at last flush? The
> periodic
> flush could be configurable, for example every 30 minutes or
> after x rows
> updated/inserted.
>
> There is no such facility implemented for UNLOGGED TABLEs. That
> could be a feature request though.
>
> Well, that is half right anyway. UNLOGGED tables obey checkpoints just
> like any other table. The missing feature is an option to
> leaved restored the last checkpoint. Instead, not knowing whether there
> were changes since the last checkpoint, the system truncated the relation.
>
> What use case is there for a behavior that the last checkpoint data is
> left on the relation upon restarting - not knowing whether it was
> possible the other data could have been written subsequent?

Yeah, this is not something that would be very easy to accomplish,
because a buffer can get evicted and written to disk at any point. It
wouldn't be too hard to read every unlogged table during recovery and
see if there are any pages that were written after the last checkpoint,
but that obviously won't be very fast.

Actually, I suppose we could dedicate a fork for unlogged tables and use
that to record the newest LSN of any page that's been written out. But
if you have much of any write activity on the table that's probably
going to be completely useless.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Alvaro Herrera 2015-04-13 21:13:12 Re: unlogged tables
Previous Message David G. Johnston 2015-04-13 20:49:16 Re: unlogged tables