* 第一次查看long_query_time参数,PROCESSLIST_ID=307,308,309 都是一样的,都是300s
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
| 388 | long_query_time | 300.000000 | 388 | 307 | dba | localhost | Sleep | NULL |
| 389 | long_query_time | 300.000000 | 389 | 308 | dba | localhost | Query | Sending data |
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
4 rows in set (0.00 sec)
* 我们再PROCESSLIST_ID=308的session上进行设置long_query_time=100,我们能看到这个时候所有的session都还是300,没有生效
dba:(none)> set global long_query_time=100;
Query OK, 0 rows affected (0.00 sec)
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
| 388 | long_query_time | 300.000000 | 388 | 307 | dba | localhost | Sleep | NULL |
| 389 | long_query_time | 300.000000 | 389 | 308 | dba | localhost | Query | Sending data |
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
4 rows in set (0.00 sec)
* 接下来,我们再断开309,重连时,processlist id 应该是310,这时候的结果就是100s了。这一点说明,在执行set global参数后进来的session才会生效,对当前session和之前的session不生效
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
| 388 | long_query_time | 300.000000 | 388 | 307 | dba | localhost | Sleep | NULL |
| 389 | long_query_time | 300.000000 | 389 | 308 | dba | localhost | Query | Sending data |
+-----------+-----------------+----------------+-----------+----------------+------------------+------------------+---------------------+---------------------------------------------------------------+
4 rows in set (0.00 sec)