diff --git a/db/constraints.sql b/db/constraints.sql index b2a03684ca..9859a7e889 100644 --- a/db/constraints.sql +++ b/db/constraints.sql @@ -15,8 +15,9 @@ alter table user add index user_name(name), add index user_tot (total_credit desc), -- db_dump.C - add index user_avg (expavg_credit desc); + add index user_avg (expavg_credit desc), -- db_dump.C + add index user_email_time (email_addr_change_time); alter table team add unique(name), diff --git a/html/inc/boinc_db.inc b/html/inc/boinc_db.inc index ebaa5a635e..cf33585adb 100644 --- a/html/inc/boinc_db.inc +++ b/html/inc/boinc_db.inc @@ -187,7 +187,7 @@ class BoincUser { static function lookup_prev_email_addr($email_addr) { $email_addr = strtolower(BoincDb::escape_string($email_addr)); $mytime = time() - 604800; - return self::lookup("previous_email_addr='$email_addr' and email_addr_change_time > $mytime"); + return self::lookup("email_addr_change_time > $mytime and previous_email_addr='$email_addr'"); } // name is not necessarily unique // diff --git a/html/ops/db_update.php b/html/ops/db_update.php index 874e57e89c..31fe2723e2 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -1107,6 +1107,7 @@ function update_4_19_2018() { add column previous_email_addr varchar(254) not null default '', add column email_addr_change_time double not null default 0 "); + do_query("alter table user add index user_email_time (email_addr_change_time)"); } // Updates are done automatically if you use "upgrade".