The accepted answer seems to be wrong. since it suggests using found_rows () after a query with LIMIT in it.
ANSWER : this is about RETURN 1 and in some cases 0 as a result of found_rows ();
this happens when some other request is called after your first choice. especially when you use the IDE or any client to fulfill your requests, some additional βpreparatoryβ requests are executed before and after your request.
and found_rows () will return the number of the result returned by running the LAST request on the server. which in this case is not the one we expect.
and therefore the error is RETURN 1 or 0.
Verification: You can verify this by enabling the general log on your server and running the queries. you will see a couple of additional queries related between the "first query and the query for the found row".
FIX stored procedure or old COUNT (*).
performance is reasonable, there is hardly any difference.
ADDITIONAL
if your object needs to find the total number of rows returned, then this will be fine. and using SQL_CALC_FOUND_ROWS becomes irrelevant.
here is a general rule, LIMIT is not required for found rows, not SQL_CALC_FOUND_ROWS. But three of them can be used together to give a very useful result.
those. at startup something like.
SELECT SQL_CALC_FOUND_ROWS * from some_table_name LIMIT 0,10; SELECT FOUND_ROWS();
We will get the number of rows that would be returned by the query if we would execute SELECT * from sometable_name; those. without limitation.
saying that
SELECT * from some_table_name LIMIT 0, 10; SELECT FOUND_ROWS();
will give us the total number of results that the cos limit will be & lt = 10. and does not use any practical purposes, but this is NOT a mistake.