The slow log helps find commands that take a long time to run in Redis. This helps you see what makes your database slow.
0
0
Slow log for performance analysis in Redis
Introduction
You want to find which commands are slowing down your Redis server.
You need to improve the speed of your Redis database.
You want to check if some commands take longer than expected.
You want to monitor Redis performance during heavy use.
You want to debug performance issues in your Redis setup.
Syntax
Redis
SLOWLOG GET [count] SLOWLOG LEN SLOWLOG RESET
SLOWLOG GET [count] shows the slow commands, optionally limited by count.
SLOWLOG LEN shows how many slow log entries are stored.
SLOWLOG RESET clears all slow log entries.
Examples
Shows the 5 most recent slow commands recorded by Redis.
Redis
SLOWLOG GET 5Shows the total number of slow log entries currently stored.
Redis
SLOWLOG LEN
Clears all slow log entries to start fresh.
Redis
SLOWLOG RESET
Sample Program
This example clears the slow log, sets the threshold to 10 milliseconds, runs a fast command (PING), then a slow command (DEBUG SLEEP 0.02), and finally gets the last 2 slow log entries.
Redis
SLOWLOG RESET CONFIG SET slowlog-log-slower-than 10000 PING DEBUG SLEEP 0.02 SLOWLOG GET 2
OutputSuccess
Important Notes
The slow log records commands that take longer than the configured threshold (in microseconds).
By default, the slow log threshold is 10,000 microseconds (10 ms).
Use CONFIG SET slowlog-log-slower-than 0 to log all commands.
Summary
The slow log helps find slow commands in Redis.
You can view, count, and clear slow log entries.
Adjust the threshold to control what is logged.