SDB303[high]Rewrites
Table switched between LOGGED and UNLOGGED
SET LOGGED / SET UNLOGGED rewrites the table.
Why it's risky in PostgreSQL
Changing persistence rewrites the table and its indexes under an ACCESS EXCLUSIVE lock.
What triggers it, and the safer way
ALTER TABLE sessions SET LOGGED;-- Create the table with the intended persistence from the start.
CREATE UNLOGGED TABLE cache_entries (k text PRIMARY KEY, v text);Suppress it when you're sure
Put this comment on the line before the statement. The reason is required and shows in the report.
-- shadowdb:allow SDB303 <why this is safe here>Applies to PostgreSQL 14, 15, 16, 17.