All pastes #266460 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-04 03:51 UTC
rendered paste body
CREATE TABLE `comentarios_0` (
  `index` int(25) NOT NULL auto_increment,
  `id` int(9) NOT NULL default '0',
  `idcom` int(9) NOT NULL default '0',
  `nickcom` varchar(15) NOT NULL default '',
  `comentario` text NOT NULL,
  `reply` char(1) NOT NULL default '',
  `ip` varchar(15) NOT NULL default '',
  `fecha` bigint(20) NOT NULL default '0',
  PRIMARY KEY  (`index`),
  KEY `id` (`id`),
  KEY `idcom` (`idcom`)
) ENGINE=MyISAM AUTO_INCREMENT=10886309 DEFAULT CHARSET=latin1

explain SELECT `index`,id, idcom, nickcom, comentario, reply, ip, fecha  FROM  `genteya_comentarios`.`comentarios_0` WHERE `idcom`=2 ORDER BY  `index` DESC LIMIT 0,125;

+----+-------------+---------------+------+---------------+-------+---------+-------+------+-----------------------------+
| id | select_type | table         | type | possible_keys | key   | key_len | ref   | rows | Extra                       |
+----+-------------+---------------+------+---------------+-------+---------+-------+------+-----------------------------+
|  1 | SIMPLE      | comentarios_0 | ref  | idcom         | idcom | 4       | const | 1890 | Using where; Using filesort | 
+----+-------------+---------------+------+---------------+-------+---------+-------+------+-----------------------------+

ALTER TABLE `genteya_comentarios`.`comentarios_0` DROP INDEX `idcom` ,
ADD INDEX `idcom` ( `idcom` , `index` );

explain SELECT `index`,id, idcom, nickcom, comentario, reply, ip, fecha  FROM  `genteya_comentarios`.`comentarios_0` WHERE `idcom`=2 ORDER BY  `index` DESC LIMIT 0,125;

+----+-------------+---------------+------+---------------+-------+---------+-------+------+-------------+
| id | select_type | table         | type | possible_keys | key   | key_len | ref   | rows | Extra       |
+----+-------------+---------------+------+---------------+-------+---------+-------+------+-------------+
|  1 | SIMPLE      | comentarios_0 | ref  | idcom         | idcom | 4       | const | 1122 | Using where | 
+----+-------------+---------------+------+---------------+-------+---------+-------+------+-------------+