2 INSERT INTO subscription_delivery_in_progress (id, claimant
, claimed
, claim_expires
)
3 SELECT id, $
(claimant
) AS claimant
, now() AS claimed
, now() + $
(claimTimeoutSeconds
)::text::interval AS claim_expires
4 FROM subscription_delivery_needed
5 ORDER BY topic_id
-- cluster topics together, so processing nodes can cache topic content
7 FOR UPDATE OF subscription_delivery_needed SKIP LOCKED
8 ON CONFLICT (id) DO UPDATE
10 claimant
= $
(claimant
),
12 claim_expires
= now() + $
(claimTimeoutSeconds
)::text::interval