Redis Slowlog Command
Redis slowlog is a logging system in Redis used to record the execution time of queries.
The query execution time refers to the time spent solely on executing a query command, excluding I/O operations such as client response and sending replies.
Additionally, the slow log is stored in memory, making it very fast for read and write operations. You can use it without concern that enabling the slow log will adversely affect Redis performance.
Syntax
The basic syntax for the redis slowlog command is as follows:
redis 127.0.0.1:6379> SLOWLOG subcommand [argument]
Available Versions
= 2.2.12
Return Value
Depends on the specific command, returning different values.
Examples
View log information:
redis 127.0.0.1:6379> slowlog get 2
1) 1) (integer) 14
2) (integer) 1309448221
3) (integer) 15
4) 1) "ping"
2) 1) (integer) 13
2) (integer) 1309448128
3) (integer) 30
4) 1) "slowlog"
2) "get"
3) "100"
View the current number of logs:
redis 127.0.0.1:6379> SLOWLOG LEN
(integer) 14
Use the SLOWLOG RESET command to clear the slow log:
redis 127.0.0.1:6379> SLOWLOG LEN
(integer) 14
redis 127.0.0.1:6379> SLOWLOG RESET
OK
redis 127.0.0.1:6379> SLOWLOG LEN
(integer) 0