long_query_time
Seconds a statement must run to be written to the slow query log.
- 기본값
10- Range
- 0 to 31536000 seconds, with microsecond resolution
- Restart needed
- 아니요
- Default checked on
- MySQL 8.4 LTS
기능
Fractional values work down to microseconds. The time excludes waiting for table locks.
기본값
10. 10 seconds (MySQL 8.4).
Check the current value
SHOW GLOBAL VARIABLES LIKE 'long_query_time'; SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME FROM performance_schema.variables_info WHERE VARIABLE_NAME = 'long_query_time';
Change it
SET SESSION long_query_time = 0.5; -- this connection SET GLOBAL long_query_time = 0.5; -- new connections, until restart SET PERSIST long_query_time = 0.5; -- new connections, and after restarts
No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When to change it
10 seconds misses most problems; 0.5-1 second is a common production value.
What can go wrong
0 logs every statement: useful briefly for sampling, too heavy to leave on.
The closest setting on other engines
| 엔진 | 설정 | 기본값 | Restart |
|---|---|---|---|
| MySQL |
long_query_time this page
|
10 |
아니요 |
| PostgreSQL |
log_min_duration_statement
|
-1 (disabled) |
아니요 |
| SQL Server |
QUERY_STORE
|
ON (READ_WRITE) |
아니요 |
Questions about long_query_time
What is the default value of long_query_time in MySQL?
10. 10 seconds (MySQL 8.4).
Does changing long_query_time require a restart?
No. No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When should I change long_query_time?
10 seconds misses most problems; 0.5-1 second is a common production value.
Back to all MySQL settings, or check the MySQL manual for every option.
Check long_query_time on your own server
SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.