Is there an effect on query speed when using SQL_CALC_FOUND_ROWS in MySQL?

The other day, I found that the function FOUND_ROWS()( here ) in MySQL and the corresponding option SQL_CALC_FOUND_ROWS. Later it looks especially useful (instead of running a second query to get the number of rows).

I’m wondering what effect does adding SQL_CALC_FOUND_ROWSto a query have on speed ?

I guess this will be much faster than running the second query to count the rows, but whether it will be completely different. In addition, I found a query restriction to make it much faster (for example, when you get the first 10 rows of 1000 each). Will adding SQL_CALC_FOUND_ROWSto a request with a small limit make the request run much slower?

I know I can check it out, but I'm curious about common practices here.

+3
source share
4 answers

To calculate SQL_CALC_FOUND_ROWS, the query will be executed as if it were not installed LIMIT, but the result set sent to the client will obey LIMIT.


Update: for COUNT (*) operations that will only use the index, SQL_CALC_FOUND_ROWSslower ( link ).

+2
source

When I was at the MySQL conference in 2008, part of one session was devoted to just that - the standards between SQL_CALC_FOUND_ROWSand the individual SELECT.

, , SQL_CALC_FOUND_ROWS - , , , . .

, , .

...

:. Hrm, google , : http://beerpla.net/2008/04/16/mysql-conference-liveblogging-mysql-performance-under-a-microscope-the-tobias-and-jay-show-wednesday-200pm/. Google , .

+2

, , , , .

, , - . .

0

SQL ( SQL- ). , , MySql , . Btw. , .

0

Source: https://habr.com/ru/post/1710927/


All Articles