All pastes #446739 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-18 17:09 UTC
rendered paste body
CREATE TABLE `album_fotos` (
  `id_album` int(6) unsigned NOT NULL auto_increment,
  `idu` varchar(32) NOT NULL,
  `id_usuario` int(10) unsigned NOT NULL default '0',
  `numero_fotos` int(3) unsigned NOT NULL default '0',
  `inhabilitado` enum('0','1') NOT NULL default '0',
  `monitorizado_reportes` enum('0','1') NOT NULL default '0',
  `titulo` varchar(75) NOT NULL,
  `ip` varchar(15) NOT NULL,
  `fecha_creacion` int(10) unsigned NOT NULL default '0',
  `fecha_ultimo_upload` int(10) unsigned NOT NULL default '0',
  `fecha_fin_monitorizacion` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id_album`),
  KEY `id_album` (`inhabilitado`,`id_usuario`,`id_album`),
  KEY `idu` (`idu`(10))
) ENGINE=MyISAM AUTO_INCREMENT=208386 DEFAULT CHARSET=latin1 


mysql> SELECT SQL_NO_CACHE COUNT(*) FROM `album_fotos` WHERE `id_usuario`='2';
+----------+
| COUNT(*) |
+----------+
|        7 |
+----------+
1 row in set (0.17 sec)

mysql> SELECT SQL_NO_CACHE COUNT(*) FROM `album_fotos` WHERE `inhabilitado` AND `id_usuario`='2';
+----------+
| COUNT(*) |
+----------+
|        7 |
+----------+
1 row in set (0.32 sec)

mysql> 

mysql> EXPLAIN SELECT SQL_NO_CACHE COUNT(*) FROM `album_fotos` WHERE `id_usuario`='2';
+----+-------------+-------------+-------+---------------+----------+---------+------+--------+--------------------------+
| id | select_type | table       | type  | possible_keys | key      | key_len | ref  | rows   | Extra                    |
+----+-------------+-------------+-------+---------------+----------+---------+------+--------+--------------------------+
|  1 | SIMPLE      | album_fotos | index | NULL          | id_album | 9       | NULL | 208343 | Using where; Using index |
+----+-------------+-------------+-------+---------------+----------+---------+------+--------+--------------------------+
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT SQL_NO_CACHE COUNT(*) FROM `album_fotos` WHERE `inhabilitado` AND `id_usuario`='2';
+----+-------------+-------------+-------+---------------+----------+---------+------+--------+--------------------------+
| id | select_type | table       | type  | possible_keys | key      | key_len | ref  | rows   | Extra                    |
+----+-------------+-------------+-------+---------------+----------+---------+------+--------+--------------------------+
|  1 | SIMPLE      | album_fotos | index | NULL          | id_album | 9       | NULL | 208343 | Using where; Using index |
+----+-------------+-------------+-------+---------------+----------+---------+------+--------+--------------------------+
1 row in set (0.00 sec)