The current publish worker loop is:
SELECT N envelopes
... process ...
INSERT as originator envelope
... check if it was inserted ...
DELETE staged envelope
This is likely creating delete bloat / vacuum pressure.
Can this process become more efficient? Ideas:
- SKIP LOCKED + delete in same transaction
- claim + mark processed_at, delete later in another sweeper/pruner process
- append only, partition and drop old partitions?