All pastes #912822 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-21 17:39 UTC
rendered paste body
mysql> SHOW CREATE TABLE forumread\G*************************** 1. row ***************************
       Table: forumread
Create Table: CREATE TABLE `forumread` (
  `userid` int(10) unsigned NOT NULL default '0',
  `forumid` smallint(5) unsigned NOT NULL default '0',
  `readtime` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`forumid`,`userid`),
  KEY `cover` (`forumid`,`userid`,`readtime`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT subscribeforumid, forum.forumid, lastpost, lastposter, lastthread, lastthreadid, lasticonid, threadcount, replycount, lastpostid
    -> , forumread.readtime AS forumread
    -> FROM forum AS forum
    -> LEFT JOIN subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = 1729)
    ->  LEFT JOIN forumread AS forumread ON (forumread.forumid = forum.forumid AND forumread.userid = 1729);
+----+-------------+----------------+--------+------------------+----------+---------+---------------------------------+------+-------------+
| id | select_type | table          | type   | possible_keys    | key      | key_len | ref                             | rows | Extra       |
+----+-------------+----------------+--------+------------------+----------+---------+---------------------------------+------+-------------+
|  1 | SIMPLE      | forum          | ALL    | NULL             | NULL     | NULL    | NULL                            |  508 |             | 
|  1 | SIMPLE      | subscribeforum | eq_ref | subindex,forumid | subindex | 6       | const,totalwar_vb.forum.forumid |    1 | Using index | 
|  1 | SIMPLE      | forumread      | eq_ref | PRIMARY,cover    | PRIMARY  | 6       | totalwar_vb.forum.forumid,const |    1 |             | 
+----+-------------+----------------+--------+------------------+----------+---------+---------------------------------+------+-------------+
3 rows in set (0.00 sec)

mysql> EXPLAIN SELECT subscribeforumid, forum.forumid, lastpost, lastposter, lastthread, lastthreadid, lasticonid, threadcount, replycount, lastpostid , forumread.readtime AS forumread FROM forum AS forum LEFT JOIN subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = 1729)  LEFT JOIN forumread AS forumread FORCE INDEX (cover) ON (forumread.forumid = forum.forumid AND forumread.userid = 1729);
+----+-------------+----------------+--------+------------------+----------+---------+---------------------------------+------+-------------+
| id | select_type | table          | type   | possible_keys    | key      | key_len | ref                             | rows | Extra       |
+----+-------------+----------------+--------+------------------+----------+---------+---------------------------------+------+-------------+
|  1 | SIMPLE      | forum          | ALL    | NULL             | NULL     | NULL    | NULL                            |  508 |             | 
|  1 | SIMPLE      | subscribeforum | eq_ref | subindex,forumid | subindex | 6       | const,totalwar_vb.forum.forumid |    1 | Using index | 
|  1 | SIMPLE      | forumread      | ref    | cover            | cover    | 6       | totalwar_vb.forum.forumid,const |    1 | Using index | 
+----+-------------+----------------+--------+------------------+----------+---------+---------------------------------+------+-------------+
3 rows in set (0.00 sec)