From f01bd675c0a6cb2d7832053cef23718d9783d8f9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 7 Nov 2004 21:53:55 +0000 Subject: - Performance improvement: made 'sid' the primary key of the sessions table. That should improve performance of session handling as well improve performance of the "Who's online"-block. Drupal.org's sessions table contains appr. 40.000 sessions on a slow day and rendering the "Who's online"-block became a performance bottleneck. This change has yet to be tested on a busy site so things might go wrong. --- modules/user.module | 2 +- modules/user/user.module | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/user.module b/modules/user.module index 7c5ca77be..d6ee673df 100644 --- a/modules/user.module +++ b/modules/user.module @@ -563,7 +563,7 @@ function user_block($op = 'list', $delta = 0, $edit = array()) { $time_period = variable_get('user_block_seconds_online', 2700); // Perform database queries to gather online user lists. - $guests = db_fetch_object(db_query('SELECT COUNT(DISTINCT(sid)) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period)); + $guests = db_fetch_object(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period)); $users = db_query('SELECT DISTINCT(uid), MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC', time() - $time_period ); $total_users = db_num_rows($users); diff --git a/modules/user/user.module b/modules/user/user.module index 7c5ca77be..d6ee673df 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -563,7 +563,7 @@ function user_block($op = 'list', $delta = 0, $edit = array()) { $time_period = variable_get('user_block_seconds_online', 2700); // Perform database queries to gather online user lists. - $guests = db_fetch_object(db_query('SELECT COUNT(DISTINCT(sid)) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period)); + $guests = db_fetch_object(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period)); $users = db_query('SELECT DISTINCT(uid), MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC', time() - $time_period ); $total_users = db_num_rows($users); -- cgit v1.2.3