Hi,

Check the section about How MySQL Optimizes queries for you version - there
is a bit about how indices are not used when calling a function that may be
relevant.

Hope it helps

Quentin

-----Original Message-----
From: Leon Noble [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 1 November 2001 11:26 p.m.
To: [EMAIL PROTECTED]
Subject: Query speed


Hi All,

Tried the following three statements and they are wither too slow or do not
give me what I want. Basically what I want is to search for records for a
whole month and display totals for that month for each individual day. The
date field is indexed.

Tried......

select count(num) as mycount from table_name where month(date) = 08 and
year(date) = 2001 and action = 1 group by dayofmonth(date);

this one takes too long........


As does this one.....

select dayofmonth(date) as mydate, count(num) as mycount from table_name
where month(date)=08 and year(date)=2001 and action=1 group by
dayofmonth(date);


and this one just outputs the total figure for the month

select dayofmonth(date) as mydate, count(num) as mycount from table_name
where date='TO_DAYS(2001-08-01) - TO_DAYS(2001-08-31)' and action=1 group by
dayofmonth(date);


can anyone help to point me in the right direction.

many thanks


Leon.


---------------------------------------------------------------------
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

The information contained in this email is privileged and confidential
and intended for the addressee only. If you are not the intended 
recipient, you are asked to respect that confidentiality and not 
disclose, copy or make use of its contents. If received in error 
you are asked to destroy this email and contact the sender immediately. 
Your assistance is appreciated.

---------------------------------------------------------------------
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