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. --- database/database.mysql | 2 +- database/updates.inc | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'database') diff --git a/database/database.mysql b/database/database.mysql index f8be88bbc..7e8478852 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -567,7 +567,7 @@ CREATE TABLE sessions ( timestamp int(11) NOT NULL default '0', session longtext, KEY uid (uid), - KEY sid (sid), + PRIMARY KEY sid (sid), KEY timestamp (timestamp) ) TYPE=MyISAM; diff --git a/database/updates.inc b/database/updates.inc index e135ae431..148119757 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -86,7 +86,8 @@ $sql_updates = array( "2004-09-17" => "update_107", "2004-10-16" => "update_108", "2004-10-18" => "update_109", - "2004-10-31: first update since Drupal 4.5.0 release" => "update_110" + "2004-10-31: first update since Drupal 4.5.0 release" => "update_110", + "2004-11-07" => "update_111" ); function update_32() { @@ -1966,6 +1967,16 @@ function update_110() { return $ret; } +function update_111() { + $ret = array(); + + if ($GLOBALS['db_type'] == 'mysql') { + $ret[] = update_sql('ALTER TABLE {sessions} ADD PRIMARY KEY sid (sid)'); + } + + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); -- cgit v1.2.3