Page 1 of 1

SELECT COUNT(*)

Posted: Sun Oct 08, 2006 1:29 pm
by Luke
Is a query like this:

Code: Select all

SELECT COUNT( * ) AS count
FROM `table`
WHERE `email` LIKE 'Ploo%';
faster than a query like this?

Code: Select all

SELECT *
FROM `table`
WHERE `email` LIKE 'Ploo%'
If so why? Wouldn't it still have to look through the same amount of records? Thanks.

Posted: Sun Oct 08, 2006 1:36 pm
by Weirdan
Wouldn't it still have to look through the same amount of records?
It would. But it wouldn't send them to client.

Posted: Tue Oct 10, 2006 2:44 am
by CoderGoblin
Even better with large tables is to limit the result

Code: Select all

SELECT COUNT(table_id) FROM tablename
. You should, if the table has a large number of columns notice quite a difference.