Deleting a document walked its subtree with one query per document and
destroyed each in a serial post-order recursion, so large subtrees could
exceed the request statement_timeout.
Resolve the subtree with the existing recursive CTE helper and load the
children in a single query instead. Documents are still destroyed one at
a time so model hooks run for each, and deepest-first ordering is kept.
The subtree lookup also dropped the options it was passed, so it ran
outside the request transaction.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>