Get the App
SLTechnology News&Howtos  ›  Database  › 

Redis slow query log

Shulou Source: shulou.com Published: 2022-06-01 11:32:55 09月24日 Update

1. What is Slow Log?

Slow log is the logging system Redis uses to record query execution time.

Query execution time refers to the time it takes to execute a query command alone, excluding IO operations such as client talking and sending replies.

In addition, slow log is stored in memory, reading and writing speed is very fast, so you can use it with confidence, do not have to worry about slowing down Redis because of slow log.

2. View Slow Query Log Parameters

127.0.0.1:6379> config get slowlog*

1) "slowlog-log-slower-than"

2)"10000" --units of subtle

3)"slowlog-max-len" --Maximum number of slow query logs saved

4) "128"

3. Dynamically modifiable, dynamic parameters

127.0.0.1:6379> config set slowlog-log-slower-than 100000

OK

127.0.0.1:6379> config set slowlog-max-len 256

OK

127.0.0.1:6379> config get slowlog*

1) "slowlog-log-slower-than"

2) "100000"

3) "slowlog-max-len"

4) "256"

4. view command

127.0.0.1:6379> slowlog get 2

1)1) (integer) 1 #log identifier for uniqueness

2)(integer) 1480331288 #The point in time at which the logged command was executed, expressed in UNIX timestamp format

3)(integer) 43136 #Query execution time in microseconds

4)1) "config" #commands executed, arranged in array form, complete command config get slowlog*

2) "get"

3) "slowlog*"

2) 1) (integer) 0

2) (integer) 1480331280

3) (integer) 54158

4) 1) "info"

127.0.0.1:6379>

127.0.0.1:6379> slowlog len

(integer) 2

5. clear command

127.0.0.1:6379> slowlog reset

OK

127.0.0.1:6379> slowlog get 2

(empty list or set)

127.0.0.1:6379>

6. help

127.0.0.1:6379> help slowlog

SLOWLOG subcommand [argument]

summary: Manages the Redis slow queries log

since: 2.2.12

group: server

Tags: Query command time log dynamic unit parameter speed subtlety memory uniqueness client client form array quantity identity identifier format system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Docker Shulou Technology Shulou Information