Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created January 5, 2018 00:03
Show Gist options
  • Save mahmoud/68759bc25e2c1489ee3dfc3b9f4ec09d to your computer and use it in GitHub Desktop.
Save mahmoud/68759bc25e2c1489ee3dfc3b9f4ec09d to your computer and use it in GitHub Desktop.
postgres queue get
DELETE FROM {table_name}
WHERE id = (
SELECT id
FROM {0}
WHERE deliver_after <= now()
AND q_name IN (SELECT unnest({q_names}))
ORDER BY priority DESC, created_at
FOR UPDATE SKIP LOCKED
LIMIT 1
)
RETURNING *;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment