PostgreSQL 17 runners are live
All rules

SDB105[medium]Destructive

UPDATE or DELETE without WHERE

The statement touches every row of an existing table.

Why it's risky in PostgreSQL

A migration that updates or deletes every row runs as one long transaction: it holds row locks on the whole table, bloats it with dead rows and writes WAL for all of them. Sometimes that's the intent (a backfill); often a WHERE clause was forgotten.

On a large table, batch the work so each transaction is short.

What triggers it, and the safer way

unsafe.sql
UPDATE users SET plan = 'free';
safer.sql
UPDATE users SET plan = 'free' WHERE plan IS NULL AND id BETWEEN 1 AND 10000;

Suppress it when you're sure

Put this comment on the line before the statement. The reason is required and shows in the report.

suppression
-- shadowdb:allow SDB105 <why this is safe here>

Applies to PostgreSQL 14, 15, 16, 17.