----- Original Message ----- From: "Martin Gallagher" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Saturday, April 08, 2006 6:34 PM
Subject: COUNT() Efficiency


Hi,

If I did a query like:

SELECT COUNT(id) AS count1, COUNT(id) AS count2 FROM table WHERE id<100

Would MySQL run the COUNT() calculation once or twice?


I don't know the answer to your question but why would you want to count in the same column of the same table twice in the same query?

I'm not very knowledgeable about MySQL performance - I'm mostly a DB2 guy - but doesn't MySQL have an Explain command that will tell you what access path you are getting? If it does, your best bet would be to try your query and do an Explain to see what it actually does; it should be pretty clear whether the count() is being done once or twice.

--
Rhino


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.0/304 - Release Date: 07/04/2006


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to