Commit 2a93567b authored by Vincent Pelletier's avatar Vincent Pelletier

Make SQL(Queue|Dict)_getPriority use index more efficiently.

For some reason, MIN() doesn't use the index, while ORDER BY + LIMIT does.
Also, provide a more helpful error when assertion fails.
parent 8e01f703
......@@ -132,11 +132,10 @@ class SQLBase(Queue):
def _getPriority(self, activity_tool, method, default):
result = method()
assert len(result) == 1
priority = result[0]['priority']
if priority is None:
priority = default
return priority
if not result:
return default
assert len(result) == 1, len(result)
return result[0]['priority']
def _retryOnLockError(self, method, args=(), kw={}):
while True:
......
......@@ -9,9 +9,10 @@ class_file:
</dtml-comment>
<params>
</params>
SELECT MIN(`priority`) AS `priority` FROM
SELECT `priority` FROM
message
WHERE
processing_node = 0
AND date <= UTC_TIMESTAMP()
ORDER BY priority
LIMIT 1
......@@ -9,9 +9,10 @@ class_file:
</dtml-comment>
<params>
</params>
SELECT MIN(`priority`) AS `priority` FROM
SELECT `priority` FROM
message_queue
WHERE
processing_node = 0
AND date <= UTC_TIMESTAMP()
ORDER BY priority
LIMIT 1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment