Skip to content

Instantly share code, notes, and snippets.

@lessless
Last active June 23, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lessless/33215d0c147645db721e74e07498ac53 to your computer and use it in GitHub Desktop.
Save lessless/33215d0c147645db721e74e07498ac53 to your computer and use it in GitHub Desktop.
Limit (cost=29780.02..29781.27 rows=100 width=18) (actual time=873.119..873.220 rows=100 loops=1)
-> LockRows (cost=29780.02..32279.42 rows=199952 width=18) (actual time=873.117..873.213 rows=100 loops=1)
-> Sort (cost=29780.02..30279.90 rows=199952 width=18) (actual time=873.095..873.117 rows=100 loops=1)
Sort Key: priority DESC, times_failed
Sort Method: external sort Disk: 5472kB
-> Seq Scan on campaign_jobs c0 (cost=0.00..22138.00 rows=199952 width=18) (actual time=0.534..279.926 rows=200000 loops=1)
Filter: (((status = 0) AND (id <> ALL ('{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48}'::integer[]))) OR ((status = 2) AND (failed_at > '2017-06-22 03:18:09'::timestamp without time zone)) OR ((status = 1) AND (started_at < '2017-06-23 03:11:09'::timestamp without time zone)))
Planning time: 1.794 ms
Execution time: 904.172 ms
(9 rows)
SELECT c0."id" FROM "campaign_jobs" AS c0
WHERE (((c0."status" = 0) AND NOT (c0."id" = ANY(array[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]))))
OR ((c0."status" = 2) AND (c0."failed_at" > '2017-06-22 03:18:09'))
OR ((c0."status" = 1) AND (c0."started_at" < '2017-06-23 03:11:09'))
ORDER BY c0."priority" DESC, c0."times_failed"
LIMIT 100 FOR UPDATE SKIP LOCKED;
SELECT c0."id" FROM "campaign_jobs" AS c0
WHERE (((c0."status" = $1) AND NOT (c0."id" = ANY($2))))
OR ((c0."status" = $3) AND (c0."failed_at" > $4))
OR ((c0."status" = $5) AND (c0."started_at" < $6))
ORDER BY c0."priority" DESC, c0."times_failed"
LIMIT $7
FOR UPDATE SKIP LOCKED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment