Search code examples
postgresqlpostgresql-9.6wal

Re-enabling table logging on PostgreSQL


We recently had a PostgreSQL database with some of the tables having WAL turned off.

ALTER TABLE some_table SET UNLOGGED;

If I was to enable the Logging again.

ALTER TABLE some_table SET LOGGED;

Does this make it as if logging was always turned on, or will I only have logging from the point I turned it back on?


Solution

  • The entire table (as-of the time logging was turned back on) gets copied into the WAL stream. It is like the table was gone for that period and then was created new and atomically loaded up with its existing contents. You won't be able to do PITR (point-in-time recovery) to see the contents of that table while it was unlogged.