On Sat, Apr 27, 2002 at 08:25:26AM -0400, Richard F. Rebel wrote:
> 
> Hello,
> 
> Perhaps I don't understand indexes but I was wondering how to improve teh
> performance of a query on an indexed column that uses MAX().
> 
> mysql> explain select max(master_mtime) from redirects where uri_scheme =
> 'http';
> 
>+-----------+------+-----------------------------+----------------+---------+-------+---------+------------+|
> table     | type | possible_keys               | key            | key_len
> | ref   | rows    | Extra      |
> 
>+-----------+------+-----------------------------+----------------+---------+-------+---------+------------+|
> redirects | ref  | full_uri_idx,uri_scheme_idx | uri_scheme_idx |      16
> | const | 7694050 | where used |
> 
>+-----------+------+-----------------------------+----------------+---------+-------+---------+------------+1
> row in set (0.01 sec)
> 
> There is an index on master_mtime but it's not listed by explain???

Indexes typically help out in the WHERE clause.  You'll notice that
MySQL selected the uri_scheme_idx index because that's the column on
which you've asked it to filter.

You might get better performance out of a compund index on
(uri_scheme, master_time), but you'll have to be the judge of that.

Jeremy
-- 
Jeremy D. Zawodny, <[EMAIL PROTECTED]>
Technical Yahoo - Yahoo Finance
Desk: (408) 349-7878   Fax: (408) 349-5454   Cell: (408) 685-5936

MySQL 3.23.47-max: up 79 days, processed 2,065,294,319 queries (302/sec. avg)

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to