Skip to content

Instantly share code, notes, and snippets.

@elhoyos
Created May 22, 2015 00:21
Show Gist options
  • Save elhoyos/a3a75969ec01370e6ae3 to your computer and use it in GitHub Desktop.
Save elhoyos/a3a75969ec01370e6ae3 to your computer and use it in GitHub Desktop.
Update specific number of jobs and return their ids
-- In psql
UPDATE jobs
SET isRunning = true
WHERE
id IN (
SELECT id
FROM jobs
WHERE
providerid = "foo" AND
callback = "crawlBar" AND
isrunning = FALSE AND
nextrun <= 1432252565689
LIMIT 50
)
RETURNING id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment