Know that you can have this statement run for n seconds by executing select sleep (n) in MySQL:[SQL]View PlainCopy
Mysql> Select Sleep (1);
+----------+
| Sleep (1) |
+----------+
| 0 |
+----------+
1 row in
Know that you can have this statement run for n seconds by executing select sleep (n) in MySQL:Mysql> Select Sleep (1); +----------+| Sleep (1) |+----------+| 0 |+----------+1 row in Set (1.00 sec)The execution time returned to the client
Know that you can have this statement run for n seconds by executing select sleep (n) in MySQL:?
1234567
mysql> selectsleep(1);+----------+| sleep(1) |+----------+| 0 |+----------+1 row in set(1.00 sec)
The
All know that by executing select sleep (n) in MySQL, you can have this statement run for N seconds: Mysql> Select Sleep (1);+----------+| Sleep (1) |+----------+| 0 |+----------+1 row in Set (1.00 sec) The execution time returned to the client
Run show processlist in mysql. There are many such processes in the database:In fact, there are too many Sleep connections in MySQL, so there are three reasons for the sleep:1. Before the client program exits, it does not call mysql_close (). [write
Use sleep in PHP to cause MySQL read failure cases and workarounds, Sleepmysql
Recently, due to project demandThe sleep function is needed to periodically fetch a heap of data from the database to perform certain operations.Sleep waits at least one
The perfect solution for too many MySQL sleep connections is too many sleep connections. What will happen to the mysql server? It seriously consumes mysql Server resources (mainly cpu and memory) and may cause mysql to crash. What causes excessive
Query the current number of connections in MySQL:Mysql> Show status like '%threads_connected% '; +-------------------+-------+| Variable_name | Value |+-------------------+-------+| threads_connected | +-------------------+-------+1 row in
There have been similar problems before, the cause of this problem from the Internet to check, there are several reasons:
Cause of excessive sleep connections?
1. Too many persistent connections used (personally, it is not appropriate to use a
PHP's garbage collection mechanism, in fact, is only for PHP itself.For mysql,php, there is no right to automatically release its things.If you do not call Mysql_close () before the page finishes executing, the connection will not be closed by MySQL.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.