List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 14 1999 5:39pm
Subject:Re: Dates and inexes
View as plain text  
At 5:23 PM -0700 7/13/99, Chris Trown wrote:
>     Today is the day for questions.
>
>     Given:
>
>mysql> show columns from foobar;
>
>+------------+----------+------+-----+---------------------+-------+
>| Field      | Type     | Null | Key | Default             | Extra |
>+------------+----------+------+-----+---------------------+-------+
>| login      | char(40) |      | MUL |                     |       |
>| start_time | datetime |      | MUL | 0000-00-00 00:00:00 |       |
>| stop_time  | datetime |      | MUL | 0000-00-00 00:00:00 |       |
>+------------+----------+------+-----+---------------------+-------+
>3 rows in set (0.01 sec)
>
>     Is there any way to make month() function go faster?  For example:
>
>select login, start_time from foobar where login='ctrown' and 
>month(start_time)=7;
>
>     shows no index when I use EXPLAIN.  For that matter, does MySQL make use
>of indexs on datetime types?

Sure, but month(start_time) isn't a datetime type.  It's an integer that
must be calculated for each row, so no index is used.

-- 
Paul DuBois, paul@stripped
Thread
Dates and inexesChris Trown14 Jul
  • Dates and inexessinisa14 Jul
    • Re: Dates and inexesChris Trown14 Jul
      • Re: Dates and inexessinisa15 Jul
      • Re: Dates and inexesMichael Widenius30 Jul
  • Re: Dates and inexesPaul DuBois14 Jul