0
0
Redisquery~10 mins

Slow log for performance analysis in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Slow log for performance analysis
Command Executed
Check Execution Time
Is Time > Threshold?
NoDo Not Log
Yes
Add Entry to Slow Log
Store Command, Time, Args
Use SLOWLOG GET to Review Entries
When a Redis command runs, its execution time is checked. If it exceeds a set threshold, the command details are saved in the slow log for later review.
Execution Sample
Redis
SLOWLOG GET 3
SLOWLOG LEN
SLOWLOG RESET
Retrieve the last 3 slow log entries, check how many entries exist, then clear the slow log.
Execution Table
StepActionExecution Time (ms)Threshold (ms)Log Entry AddedSlow Log State
1Execute SET key value0.51NoEmpty
2Execute GET key0.81NoEmpty
3Execute complex command2.31YesEntry 1: complex command logged
4Execute another command1.51YesEntry 1 & 2: commands logged
5Execute quick command0.41NoEntry 1 & 2: commands logged
6SLOWLOG GET 3---Returns last 2 entries
7SLOWLOG LEN---Returns 2
8SLOWLOG RESET---Slow log cleared
9SLOWLOG LEN---Returns 0
💡 Commands below threshold are not logged; slow log can be retrieved or reset by commands.
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 5After Step 8Final
Slow Log EntriesEmpty1 entry2 entries2 entriesClearedEmpty
Key Moments - 2 Insights
Why are some commands not added to the slow log even though they run?
Commands with execution time less than the threshold (1 ms in this example) are not logged, as shown in steps 1, 2, and 5 in the execution_table.
What happens when you run SLOWLOG RESET?
It clears all entries from the slow log, resetting it to empty, as shown in step 8 where the slow log state becomes cleared.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3. Was the command logged to the slow log?
AYes, but threshold was not checked
BYes, because execution time was above threshold
CNo, because execution time was below threshold
DNo, because slow log was full
💡 Hint
Check the 'Log Entry Added' and 'Execution Time' columns at step 3 in execution_table.
At which step does the slow log get cleared?
AStep 6
BStep 7
CStep 8
DStep 9
💡 Hint
Look at the 'Action' and 'Slow Log State' columns in execution_table.
If the threshold was increased to 3 ms, how would the slow log entries change by step 4?
ANo entries would be logged
BOnly one entry would be logged
CTwo entries would be logged as before
DAll commands would be logged
💡 Hint
Compare execution times with threshold in execution_table rows 3 and 4.
Concept Snapshot
Redis Slow Log:
- Logs commands exceeding a time threshold
- Use SLOWLOG GET to view entries
- Use SLOWLOG LEN to count entries
- Use SLOWLOG RESET to clear log
- Threshold defaults to 10 ms but can be changed
Full Transcript
The Redis slow log records commands that take longer than a set threshold to execute. When a command runs, Redis checks its execution time. If it is above the threshold, the command details are saved in the slow log. You can retrieve recent slow commands with SLOWLOG GET, check how many entries exist with SLOWLOG LEN, and clear the log with SLOWLOG RESET. Commands running faster than the threshold are not logged. This helps analyze performance issues by focusing on slow commands.