Hi,

I ran those two queries :

mysql> select count(id) from forums_data WHERE forums_data.group_id=1
AND forums_data.state=1;
+-----------+
| count(id) |
+-----------+
|      2385 |
+-----------+
1 row in set (0.11 sec)

mysql> explain select count(id) from forums_data WHERE
forums_data.group_id=1 AND forums_data.state=1;
+----+-------------+-------------+------+---------------+-----------+---------+-------------+------+-------+
| id | select_type | table       | type | possible_keys | key       |
key_len | ref         | rows | Extra |
+----+-------------+-------------+------+---------------+-----------+---------+-------------+------+-------+
|  1 | SIMPLE      | forums_data | ref  | forum_id3     | forum_id3 | 
     2 | const,const | 2265 |       |
+----+-------------+-------------+------+---------------+-----------+---------+-------------+------+-------+
1 row in set (0.00 sec)


CREATE TABLE `forums_data` (
  `id` int(10) NOT NULL auto_increment,
  `group_id` tinyint(3) unsigned NOT NULL default '1',
  `subject` varchar(255) NOT NULL default '',
  `body` text,
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
  `state` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`id`),
  KEY `forum_id3` (`state`,`group_id`)
);

I don't understand why the number rows analyzed returned by EXPLAIN
does not match the count(*) of the query. I can understand when it's
higher, but lower ?

-- 
Pooly
Webzine Rock : http://www.w-fenec.org/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to