diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-05-07 11:39:54 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-05-07 11:39:54 +0000 |
commit | 39d0fe9a3882f26ff1abe2bca2c28f94b0a8cec0 (patch) | |
tree | b2186e04ba329254abd00b8a866d16e47b9e64b3 /database | |
parent | 898e2b668879e584a13202e38a2366a0de2aabb5 (diff) | |
download | brdo-39d0fe9a3882f26ff1abe2bca2c28f94b0a8cec0.tar.gz brdo-39d0fe9a3882f26ff1abe2bca2c28f94b0a8cec0.tar.bz2 |
- User module improvements: added an 'access' column to the users-table to
keep track of the user's last access. In turn, this allowed me to:
1. Optimize the "Who's online" block. On drupal.org, the "Who's online"
block requires 32 SQL queries. With this patch, only 2 queries are
left (eliminated 30 SQL queries), and one of the two remaining queries
became appr. 20 times faster.
2. Correct the "Last access" column in the user administration overview
table. The presented data was not accurate, which led to the column
being removed. You can now sort users by 'last access'.
Diffstat (limited to 'database')
-rw-r--r-- | database/database.mysql | 4 | ||||
-rw-r--r-- | database/database.pgsql | 2 | ||||
-rw-r--r-- | database/updates.inc | 11 |
3 files changed, 13 insertions, 4 deletions
diff --git a/database/database.mysql b/database/database.mysql index 94e449f64..79d0b9c2c 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -692,7 +692,7 @@ CREATE TABLE users ( theme varchar(255) NOT NULL default '', signature varchar(255) NOT NULL default '', created int(11) NOT NULL default '0', - changed int(11) NOT NULL default '0', + access int(11) NOT NULL default '0', login int(11) NOT NULL default '0', status tinyint(4) NOT NULL default '0', timezone varchar(8) default NULL, @@ -702,7 +702,7 @@ CREATE TABLE users ( data longtext, PRIMARY KEY (uid), UNIQUE KEY name (name), - KEY changed (changed) + KEY access (access) ) TYPE=MyISAM; -- diff --git a/database/database.pgsql b/database/database.pgsql index 67f7ed631..f4d4b831a 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -687,7 +687,7 @@ CREATE TABLE users ( theme varchar(255) NOT NULL default '', signature varchar(255) NOT NULL default '', created integer NOT NULL default '0', - changed integer NOT NULL default '0', + access integer NOT NULL default '0', login integer NOT NULL default '0', status smallint NOT NULL default '0', timezone varchar(8) default NULL, diff --git a/database/updates.inc b/database/updates.inc index 084036657..2ee4acf70 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -111,7 +111,8 @@ $sql_updates = array( "2005-04-14" => "update_132", "2005-04-24" => "update_133", "2005-04-30" => "update_134", - "2005-05-06" => "update_135" + "2005-05-06" => "update_135", + "2005-05-08" => "update_136" ); function update_32() { @@ -2447,6 +2448,14 @@ function update_135() { return array(); } +function update_136() { + $ret = array(); + $ret[] = update_sql("ALTER TABLE {users} CHANGE COLUMN changed access int(11) NOT NULL default '0'"); + $ret[] = update_sql('UPDATE {users} SET access = login WHERE login > created'); + $ret[] = update_sql('UPDATE {users} SET access = created WHERE access = 0'); + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); |