diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-11-07 21:53:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-11-07 21:53:55 +0000 |
commit | f01bd675c0a6cb2d7832053cef23718d9783d8f9 (patch) | |
tree | 3edf5942363837ace9e5e8cade0cca5deb949884 /database | |
parent | 7a5884cd74c2c1d1fa19bede7805ed8be9a2053d (diff) | |
download | brdo-f01bd675c0a6cb2d7832053cef23718d9783d8f9.tar.gz brdo-f01bd675c0a6cb2d7832053cef23718d9783d8f9.tar.bz2 |
- 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.
Diffstat (limited to 'database')
-rw-r--r-- | database/database.mysql | 2 | ||||
-rw-r--r-- | database/updates.inc | 13 |
2 files changed, 13 insertions, 2 deletions
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); |