Reputation: 461
Is there a difference between using
SELECT COUNT()
against
SELECT FOUND_ROWS()
I know found rows is supposed to be used when you have a limit but if you don't use a limit is there really any difference?
Upvotes: 3
Views: 1589
Reputation: 40001
You will get the same result but in two different ways.
COUNT() is an aggregated function used when selecting and grouping data.
FOUND_ROWS() is a information function used after another select to get information on what happened.
If you only need the number of rows go with COUNT(), it's faster.
Like this:
select count(*) as number_of_rows from some_table where something = something group by something;
or
select * from some_table where something = something group by something;
select found_rows();
Upvotes: 4
Reputation: 6114
select count(*) from tablename
Is the most efficient way to get the number of rows in table tablename
SELECT FOUND_ROWS();
http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_found-rows
Upvotes: 1