On Thu, Jan 29, 2026 at 9:37 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
> The window for this sort of thing isn't very large,
That window can be arbitrary large. It includes time waiting for locks
to be released from tables of interest.
--to reduce deadlocks take strongest lock first
--TRUNCATE requare ACCESS EXCLUSIVE
LOCK tablename;
--large amount of work
SELECT pg_sleep(10);
TRUNCATE tablename;
Now you have +10 seconds for the window for tablename and all
following tables in lock order.
IMHO, hidden data loss from TRUNCATE is much more sinister, than error
from ALTER TABLE.