MySQL Forums
Forum List  »  Performance

Re: Optimizing WHERE computations
Posted by: Craig Matthews
Date: May 31, 2005 04:52AM

Hi,

Thanks Kim. That was merely an example, not an apt one I think.

My Goal:
--------
To get a count of all articles (an indexed column) for today.


My SQL:
--------
EXPLAIN
SELECT count(article_id)
FROM articles
WHERE date_format(add_date, '%Y%m%d') = curdate()+0;

I have an index on both "article_id" and "add_date" columns. Both are in the same index, article_id is the left most field, and add_date is the third one.


EXPLAIN VALUES:
-----------------

Type: Index
Possible Keys: NULL
Key Len: 60
Ref: NULL
Rows: 711 890 (This is a full table scan!)
Extra: Using where; Using index

What am I missing? It says "Using index" but the SQL is taking 7 minutes!

Options: ReplyQuote


Subject
Views
Written By
Posted
2251
May 30, 2005 11:48AM
Re: Optimizing WHERE computations
1727
May 31, 2005 04:52AM
1628
June 02, 2005 06:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.