From 407a2fce479855485dc081e5e6774fbbee08c6bb Mon Sep 17 00:00:00 2001 From: Christian Beer Date: Thu, 3 Mar 2016 14:36:15 +0100 Subject: [PATCH] Ops: combine statements for better performance No need to change the same rows in two statements. --- html/inc/util_ops.inc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/html/inc/util_ops.inc b/html/inc/util_ops.inc index 93280a8ef6..d43457af9c 100644 --- a/html/inc/util_ops.inc +++ b/html/inc/util_ops.inc @@ -360,27 +360,22 @@ if (!isset($skip_auth_ops) && array_key_exists("SERVER_PORT", $_SERVER)) { function cancel_wus_where($clause) { $q1 = "CREATE TEMPORARY TABLE tmp SELECT id FROM workunit WHERE $clause;"; $q2 = "UPDATE result SET server_state=5, outcome=5 WHERE server_state=2 AND workunitid in (SELECT id FROM tmp);"; - $q3 = "UPDATE workunit SET error_mask=error_mask|16 WHERE id in (SELECT id FROM tmp);"; - $q4 = "UPDATE workunit SET transition_time=0 WHERE id in (SELECT id FROM tmp);"; - $q5 = "DROP TABLE tmp;"; + $q3 = "UPDATE workunit SET error_mask=error_mask|16, transition_time=0 WHERE id in (SELECT id FROM tmp);"; + $q4 = "DROP TABLE tmp;"; if (!_mysql_query($q1)) { echo "MySQL command '$q1' failed:
unable to create temporary WU id table.
\n"; return 1; } else if (!_mysql_query($q2)) { echo "MySQL command '$q2' failed:
unable to cancel unsent results.
\n"; - _mysql_query($q5); + _mysql_query($q4); return 2; } else if (!_mysql_query($q3)) { - echo "MySQL command '$q3' failed:
unable to cancel workunits.
\n"; - _mysql_query($q5); + echo "MySQL command '$q3' failed:
unable to cancel workunits and trigger transitioner.
\n"; + _mysql_query($q4); return 3; - } else if (!_mysql_query($q4)) { - echo "MySQL command '$q4' failed:
unable to trigger transitioner.
\n"; - _mysql_query($q5); - return 4; - } - _mysql_query($q5); + } + _mysql_query($q4); echo "Successfully canceled WUs WHERE '$clause'
\n"; return 0; }