Index: database/database.mysql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.mysql,v
retrieving revision 1.230
diff -u -r1.230 database.mysql
--- database/database.mysql	14 Mar 2006 14:04:13 -0000	1.230
+++ database/database.mysql	16 Mar 2006 04:21:21 -0000
@@ -26,8 +26,10 @@
   uid int(10) unsigned default '0',
   timer int(10) unsigned NOT NULL default '0',
   timestamp int(11) unsigned NOT NULL default '0',
-  KEY accesslog_timestamp (timestamp),
-  PRIMARY KEY (aid)
+  PRIMARY KEY (aid),
+  KEY path (path),
+  KEY uid (uid),
+  KEY timestamp (timestamp)
 )
 /*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
@@ -870,7 +872,10 @@
   referer varchar(128) NOT NULL default '',
   hostname varchar(128) NOT NULL default '',
   timestamp int(11) NOT NULL default '0',
-  PRIMARY KEY (wid)
+  PRIMARY KEY (wid),
+  KEY uid (uid),
+  KEY type (type),
+  KEY timestamp (timestamp)
 )
 /*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
Index: database/database.pgsql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.pgsql,v
retrieving revision 1.171
diff -u -r1.171 database.pgsql
--- database/database.pgsql	4 Mar 2006 18:12:10 -0000	1.171
+++ database/database.pgsql	16 Mar 2006 04:24:23 -0000
@@ -31,6 +31,8 @@
   timestamp integer NOT NULL default '0',
   PRIMARY KEY (aid)
 );
+CREATE INDEX accesslog_path_idx ON accesslog (path);
+CREATE INDEX accesslog_uid_idx ON accesslog (uid);
 CREATE INDEX accesslog_timestamp_idx ON accesslog (timestamp);
 
 --
@@ -820,6 +822,9 @@
   timestamp integer NOT NULL default '0',
   PRIMARY KEY (wid)
 );
+CREATE INDEX watchdog_uid_idx ON watchdog (uid);
+CREATE INDEX watchdog_type_idx ON watchdog (type);
+CREATE INDEX watchdog_timestamp_idx ON watchdog (timestamp);
 
 --
 -- Insert some default values
Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.218
diff -u -r1.218 updates.inc
--- database/updates.inc	12 Mar 2006 22:25:00 -0000	1.218
+++ database/updates.inc	16 Mar 2006 05:55:20 -0000
@@ -1806,7 +1806,6 @@
         $args[] = $node->vid;
         db_query('UPDATE {node_revisions} SET '. implode(', ', $set) .' WHERE vid = %d', $args);
       }
-      
     }
 
     if ($_SESSION['system_update_178_comment'] == $_SESSION['system_update_178_comment_max'] &&
@@ -1828,3 +1827,28 @@
 
   return array();
 }
+
+function system_update_179() {
+  $ret = array();
+
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {accesslog} DROP INDEX accesslog_timestamp, ADD INDEX (timestamp)");
+      $ret[] = update_sql("ALTER TABLE {accesslog} ADD INDEX (path)");
+      $ret[] = update_sql("ALTER TABLE {accesslog} ADD INDEX (uid)");
+      $ret[] = update_sql("ALTER TABLE {watchdog} ADD INDEX (uid)");
+      $ret[] = update_sql("ALTER TABLE {watchdog} ADD INDEX (type)");
+      $ret[] = update_sql("ALTER TABLE {watchdog} ADD INDEX (timestamp)");
+      break;
+
+    case 'pgsql':
+      $ret[] = update_sql("CREATE INDEX {accesslog}_path_idx ON {accesslog} (path)");
+      $ret[] = update_sql("CREATE INDEX {accesslog}_uid_idx ON {accesslog} (uid)");
+      $ret[] = update_sql("CREATE INDEX {watchdog}_uid_idx ON {watchdog} (uid)");
+      $ret[] = update_sql("CREATE INDEX {watchdog}_type_idx ON {watchdog} (type)");
+      $ret[] = update_sql("CREATE INDEX {watchdog}_timestamp_idx ON {watchdog} (timestamp)");
+  }
+
+  return $ret;
+}
Index: modules/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics.module,v
retrieving revision 1.221
diff -u -r1.221 statistics.module
--- modules/statistics.module	1 Mar 2006 15:20:43 -0000	1.221
+++ modules/statistics.module	16 Mar 2006 05:56:19 -0000
@@ -230,7 +230,7 @@
 
   $sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid' . tablesort_sql($header);
 
-  $result = pager_query($sql, 30);
+  $result = pager_query($sql, 30, 0, 'SELECT COUNT(*) FROM {accesslog}');
   while ($log = db_fetch_object($result)) {
     $rows[] = array(
       array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
Index: modules/watchdog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/watchdog.module,v
retrieving revision 1.140
diff -u -r1.140 watchdog.module
--- modules/watchdog.module	21 Feb 2006 18:46:54 -0000	1.140
+++ modules/watchdog.module	16 Mar 2006 05:57:17 -0000
@@ -93,20 +93,20 @@
   $header = array(
     ' ',
     array('data' => t('Type'), 'field' => 'w.type'),
-    array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'),
+    array('data' => t('Date'), 'field' => 'w.timestamp', 'sort' => 'desc'),
     array('data' => t('Message'), 'field' => 'w.message'),
     array('data' => t('User'), 'field' => 'u.name'),
     array('data' => t('Operations'))
   );
 
-  $sql = "SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid";
+  $sql = "SELECT w.severity, w.type, w.timestamp, w.message, w.link, w.uid, u.name FROM {watchdog} w LEFT JOIN {users} u ON w.uid = u.uid";
   $tablesort = tablesort_sql($header);
   $type = $_SESSION['watchdog_overview_filter'];
   if ($type != 'all') {
-    $result = pager_query($sql ." WHERE w.type = '%s'". $tablesort, 50, 0, NULL, $type);
+    $result = pager_query($sql ." WHERE w.type = '%s'". $tablesort, 50, 0, "SELECT COUNT(*) FROM {watchdog} WHERE type = '". db_escape_string($type) ."'", $type);
   }
   else {
-    $result = pager_query($sql . $tablesort, 50);
+    $result = pager_query($sql . $tablesort, 50, 0, 'SELECT COUNT(*) FROM {watchdog}');
   }
 
   while ($watchdog = db_fetch_object($result)) {
