Commit 772a2d39 authored by Dries's avatar Dries
Browse files

- Patch #40545 by Moshe: reduces contention in the users table.

parent 837350ec
...@@ -75,8 +75,9 @@ function sess_write($key, $value) { ...@@ -75,8 +75,9 @@ function sess_write($key, $value) {
else { else {
db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', ip_address(), $value, time(), $key); db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', ip_address(), $value, time(), $key);
// TODO: this can be an expensive query. Perhaps only execute it every x minutes. Requires investigation into cache expiration. // Last access time is updated no more frequently than once every 180 seconds.
if ($user->uid) { // This reduces contention in the users table.
if ($user->uid && time() - $user->access > variable_get('session_write_interval', 180)) {
db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid); db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid);
} }
} }
......
Supports Markdown
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