← all rules

set-logged-unlogged

error

SET LOGGED / UNLOGGED

Why it's unsafe

ALTER TABLE ... SET LOGGED/UNLOGGED rewrites the entire table and its indexes under an ACCESS EXCLUSIVE lock.

Safe rewrite

There is no online alternative — toggling durability rewrites the table. Do it in a maintenance window, and avoid it on a large live table.

Example

Try it in the playground →

Unsafe

ALTER TABLE events SET LOGGED;

Related