As you are selecting all records (no where clause), it will scan the whole table every 
time, I believe...

does anyone know if he added the other columns to his index, or had 4 seperate indexes 
(one per column) would they be used in this operation?


> 
> Ok, I've found the optimization chapter in the manual and I'm still 
> reading it.
> Here's what I've done so far:
> 
> mysql> alter table traf_oper add index (tel), add index (telefb);
> 
> mysql> explain select tel, telefb, rutaentran, rutasalien, 
> sum(minutos) 
> as minutos from traf_oper group by 1, 2, 3, 4;
> +----+-------------+-----------+------+---------------+------+
> ---------+------+---------+---------------------------------+
> | id | select_type | table     | type | possible_keys | key  
> | key_len | 
> ref  | rows    | Extra                           |
> +----+-------------+-----------+------+---------------+------+
> ---------+------+---------+---------------------------------+
> |  1 | SIMPLE      | traf_oper | ALL  | NULL          | NULL 
> |    NULL | 
> NULL | 5014313 | Using temporary; Using filesort |
> +----+-------------+-----------+------+---------------+------+
> ---------+------+---------+---------------------------------+
> 1 row in set (0.50 sec)
> 
> mysql> describe traf_oper;
> +------------+----------+-------------------+------+-----+----
> -----+-------+
> | Field      | Type     | Collation         | Null | Key | 
> Default | Extra |
> +------------+----------+-------------------+------+-----+----
> -----+-------+
> | tel        | char(8)  | latin1_swedish_ci | YES  | MUL | 
> NULL    |       |
> | fecha      | char(8)  | latin1_swedish_ci | YES  |     | 
> NULL    |       |
> | hora       | char(6)  | latin1_swedish_ci | YES  |     | 
> NULL    |       |
> | telefb     | char(14) | latin1_swedish_ci | YES  | MUL | 
> NULL    |       |
> | tiempotasa | char(6)  | latin1_swedish_ci | YES  |     | 
> NULL    |       |
> | rutasalien | char(7)  | latin1_swedish_ci | YES  |     | 
> NULL    |       |
> | rutaentran | char(7)  | latin1_swedish_ci | YES  |     | 
> NULL    |       |
> | serie      | char(3)  | latin1_swedish_ci | YES  |     | 
> NULL    |       |
> | tipotraf   | int(1)   | binary            | YES  |     | 
> NULL    |       |
> | minutos    | int(4)   | binary            | YES  |     | 
> NULL    |       |
> +------------+----------+-------------------+------+-----+----
> -----+-------+
> 10 rows in set (0.00 sec)
> 
> So, why isn't SELECT using indexes (key = NULL, key_len = NULL)?
> Where else do I need to add indexes?
> Thanks for your help!
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
http://lists.mysql.com/[EMAIL PROTECTED]


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

Reply via email to