Skip to content

Instantly share code, notes, and snippets.

@queso
Created March 12, 2009 03:02
Show Gist options
  • Save queso/77885 to your computer and use it in GitHub Desktop.
Save queso/77885 to your computer and use it in GitHub Desktop.
SELECT * FROM `delayed_jobs` WHERE ((run_at <= '2009-03-12 02:59:22' AND (locked_at IS NULL OR locked_at < '2009-03-11 22:59:22') OR (locked_by = 'host:client1.gethandcrafted.com pid:4664')) AND failed_at IS NULL) ORDER BY priority DESC, run_at ASC LIMIT 5;
mysql> EXPLAIN SELECT * FROM `delayed_jobs` WHERE ((run_at <= '2009-03-12 03:07:11' AND (locked_at IS NULL OR locked_at < '2009-03-11 23:07:11') OR (locked_by = 'host:client1.gethandcrafted.com pid:4664')) AND failed_at IS NULL) ORDER BY priority DESC, run_at ASC LIMIT 5;
+----+-------------+--------------+------+---------------+------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+------+---------------+------+---------+------+------+-----------------------------+
| 1 | SIMPLE | delayed_jobs | ALL | run_at | NULL | NULL | NULL | 1 | Using where; Using filesort |
+----+-------------+--------------+------+---------------+------+---------+------+------+-----------------------------+
1 row in set (0.01 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment