From 49d74b5b7bc60754aef6bd051efb25813a35e7c3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 25 May 2016 12:13:44 +0530 Subject: [PATCH] [minor] [bulk] use index for priority --- frappe/email/bulk.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/email/bulk.py b/frappe/email/bulk.py index 1b3b2a2fc1..19b2c6a632 100644 --- a/frappe/email/bulk.py +++ b/frappe/email/bulk.py @@ -253,9 +253,13 @@ def flush(from_test=False): where datediff(curdate(), creation) > 3 and status='Not Sent'""", auto_commit=auto_commit) def get_email(priority): - out = frappe.db.sql("""select * from `tabBulk Email` where + use_index='' + if priority: + use_index = 'use index (priority)' + out = frappe.db.sql("""select * from `tabBulk Email` {use_index} where status='Not Sent' and send_after < %s and priority = %s - order by creation asc limit 1 for update""", (now_datetime(), priority), as_dict=1) + order by creation asc limit 1 for update""".format(use_index=use_index), + (now_datetime(), priority), as_dict=1) return out and out[0][0] or None for i in xrange(500):