Re: Optimizing WHERE computations
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!
Subject
Views
Written By
Posted
2251
May 30, 2005 11:48AM
1565
May 30, 2005 06:52PM
Re: Optimizing WHERE computations
1727
May 31, 2005 04:52AM
1581
May 31, 2005 05:35AM
1597
May 31, 2005 07:08AM
1192
May 31, 2005 07:11AM
1683
May 31, 2005 10:45AM
1865
May 31, 2005 07:19PM
1676
June 01, 2005 08:53AM
1628
June 02, 2005 06:41PM
1701
June 02, 2005 09:20PM
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.