Re: GSoC proposal - "make an unlogged table logged" - Mailing list pgsql-hackers

From Fabrízio de Royes Mello
Subject Re: GSoC proposal - "make an unlogged table logged"
Date
Msg-id CAFcNs+odxM+GLheNrVNG2C6Us787vPQWnGyLc0t33-BhF-41Ag@mail.gmail.com
Whole thread Raw
In response to Re: GSoC proposal - "make an unlogged table logged"  (Hannu Krosing <hannu@2ndQuadrant.com>)
Responses Re: GSoC proposal - "make an unlogged table logged"  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers



On Mon, Mar 3, 2014 at 2:40 PM, Hannu Krosing <hannu@2ndquadrant.com> wrote:
>
> On 03/03/2014 05:22 PM, Tom Lane wrote:
> > Stephen Frost <sfrost@snowman.net> writes:
> ...
> >> ISTR the discussion going something along the lines of "we'd have to WAL
> >> log the entire table to do that, and if we have to do that, what's the
> >> point?".
> > IIRC, the reason you'd have to do that is to make the table contents
> > appear on slave servers.  If you don't consider replication then it might
> > seem easier.
> So switch on logging and then perform CLUSTER/VACUUM FULL ?
>
> Should this work, or is something extra needed ?
>

Today I do something like that:

1) create unlogged table tmp_foo ...
2) populate 'tmp_foo' table (ETL scripts or whatever)
3) start transaction
4) lock table tmp_foo in access exclusive mode
5) update pg_class set relpersistence = 'p' where oid = 'tmp_foo':regclass
6) drop table foo; -- the old foo table
7) alter table tmp_foo rename to foo;
8) end transaction
9) run pg_repack in table 'foo'

I know it's very ugly, but works... and works for standbys too... :-)

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello

pgsql-hackers by date:

Previous
From: Kouhei Kaigai
Date:
Subject: Re: contrib/cache_scan (Re: What's needed for cache-only table scan?)
Next
From: Ashutosh Bapat
Date:
Subject: Re: Custom Scan APIs (Re: Custom Plan node)