Differences between COUNT (*) and SQL_CALC_FOUND_ROWS *

0

What is the difference between a SELECT COUNT(*) FROM tabla; and SELECT SQL_CALC_FOUND_ROWS * FROM tabla; SELECT FOUND_ROWS(); ?

According to the API it is faster SQL_CALC_FOUND_ROWS but according to other comments on the Internet is not like that.

They both count the number of records, so where is the difference and why is it used so much SQL_CALC_FOUND_ROWS and then another query to FOUND_ROWS() to get the number of records in a table?

    
asked by dddenis 18.09.2016 в 13:56
source

1 answer

-1

You will get the same result but in two different ways.

COUNT() is a aggregate function used when selecting and grouping data .

FOUND_ROWS() is an information function used after another to get information about what happened .

If you only need the number of rows use COUNT() , it's faster.

select count(*) as number_of_rows from some_table where something = something group by something;

Here you can find speed tests .

    
answered by 18.09.2016 в 13:59