MySQL Forums
Forum List  »  Performance

Re: Count massively faster than select on same query, why?!?!
Posted by: Bob Field
Date: August 03, 2006 01:41PM

Without seeing the output of EXPLAIN, I'm guessing that the query using COUNT(*) is taking advantage of the indexing and able to count the rows that way, whereas the other query has to read the table data itself to retrieve the data for all the other fields. Try a query like this:
SELECT colum1, column2, column4
FROM xyz
WHERE colum1="abc", column2="def" and "column4="ghi";
I.e., take the second query and only name the columns referenced in the WHERE clause.

Options: ReplyQuote




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.