Performance Commands

SLOWLOG-GET

SLOWLOG captures commands that exceeded a time threshold. Find the queries killing your performance without enabling full command logging.

You'll Learn

  • Reading SLOWLOG entries
  • Configuring the threshold
  • Identifying slow commands
  • Performance optimization tips
Free Download

See Your Data, Not Terminal Text

Redimo visualizes every Redis data type beautifully. Edit inline, undo mistakes, stay safe in production.

1. What Is SLOWLOG?

Redis SLOWLOG records commands that took longer than a configurable threshold. It's a built-in profiler that runs with minimal overhead.

What It Captures

  • • Timestamp of execution
  • • Command and arguments
  • • Execution time (microseconds)
  • • Client info (Redis 4+)

What It Doesn't Include

  • • Network latency
  • • Queue wait time
  • • Client processing time
  • • Only captures slow commands

2. SLOWLOG GET: View Slow Commands

SLOWLOG GET retrieves entries from the slow log. Each entry shows what ran slowly and how long it took.

Reading SLOWLOG

# Get last 10 slow commands (default)
SLOWLOG GET 10

1) 1) (integer) 14            # Entry ID
   2) (integer) 1705312245    # Unix timestamp
   3) (integer) 15234         # Duration (microseconds)
   4) 1) "KEYS"               # Command
      2) "*"                  # Arguments
   5) "192.168.1.100:52345"   # Client address
   6) "myapp"                 # Client name (if set)

2) 1) (integer) 13
   2) (integer) 1705312240
   3) (integer) 8500
   4) 1) "SMEMBERS"
      2) "huge-set"
   5) "192.168.1.101:52346"
   6) "worker-1"

# Get all entries
SLOWLOG GET

# Get specific count
SLOWLOG GET 100

Entry Fields

  • ID - Unique, incrementing identifier
  • Timestamp - When command ran (Unix time)
  • Duration - Microseconds (1000 = 1ms)
  • Command - Full command with arguments
  • Client - IP:port and name

3. Configuration

Two settings control SLOWLOG behavior:

SLOWLOG Settings

# Check current settings
CONFIG GET slowlog-log-slower-than
1) "slowlog-log-slower-than"
2) "10000"  # 10000 microseconds = 10ms

CONFIG GET slowlog-max-len
1) "slowlog-max-len"
2) "128"  # Keep last 128 entries

# Set threshold to 5ms
CONFIG SET slowlog-log-slower-than 5000

# Keep more entries
CONFIG SET slowlog-max-len 1000

# Log everything (for debugging - high overhead!)
CONFIG SET slowlog-log-slower-than 0

# Disable slowlog
CONFIG SET slowlog-log-slower-than -1

Threshold Tuning

Start with 10ms (10000). If you have too many entries, increase it. If you see no entries but have latency issues, decrease it. For debugging specific issues, temporarily set to 0 to capture everything.

4. Managing SLOWLOG

SLOWLOG Management

# Count of entries in log
SLOWLOG LEN
(integer) 42

# Clear the log
SLOWLOG RESET
OK

# Verify cleared
SLOWLOG LEN
(integer) 0

5. Common Slow Command Patterns

KEYS Pattern

# KEYS * scans entire keyspace - O(N)
4) 1) "KEYS"
   2) "user:*"
3) (integer) 125000  # 125ms!

# Fix: Use SCAN instead
SCAN 0 MATCH user:* COUNT 100

Large Collection Operations

# SMEMBERS on huge set - O(N)
4) 1) "SMEMBERS"
   2) "all-users"
3) (integer) 45000  # 45ms, set has 100k members

# Fix: Use SSCAN for iteration
SSCAN all-users 0 COUNT 100

# Or reconsider data structure

Sorted Set Range on Large Set

# ZRANGE with large range - O(log(N) + M)
4) 1) "ZRANGEBYSCORE"
   2) "leaderboard"
   3) "0"
   4) "+inf"
3) (integer) 85000  # 85ms, returned 50k members

# Fix: Limit results
ZRANGEBYSCORE leaderboard 0 +inf LIMIT 0 100

Lua Scripts

# Long-running Lua script
4) 1) "EVALSHA"
   2) "abc123..."
   3) "1"
   4) "mykey"
3) (integer) 200000  # 200ms!

# Review the script logic
# Consider breaking into smaller operations

6. Interpreting Results

Time Ranges

  • < 1000 μs - Fast (<1ms)
  • 1000-10000 μs - Acceptable (1-10ms)
  • 10000-100000 μs - Slow (10-100ms)
  • > 100000 μs - Very slow (>100ms), investigate!

Red Flags

  • • Same command appearing repeatedly
  • KEYS in any form
  • • Large unbounded ranges (LRANGE 0 -1)
  • • Sudden spikes in duration

7. Performance Investigation Workflow

Step-by-Step

# 1. Check for recent slow commands
SLOWLOG GET 50

# 2. Identify patterns
#    - Same command type?
#    - Same key patterns?
#    - Same client?

# 3. Get more context
SLOWLOG GET 100 | grep -i "keys\|smembers\|lrange"

# 4. Check the key
MEMORY USAGE problematic-key
DEBUG OBJECT problematic-key
TYPE problematic-key

# 5. If it's a collection, check size
SCARD problematic-set
HLEN problematic-hash
LLEN problematic-list
ZCARD problematic-zset

# 6. Correlate with latency spikes
INFO stats | grep instantaneous_ops_per_sec
INFO commandstats | grep calls

8. Prevention Strategies

Replace Dangerous Commands

# Instead of KEYS
SCAN 0 MATCH pattern:* COUNT 100

# Instead of SMEMBERS on large set
SSCAN large-set 0 COUNT 100

# Instead of HGETALL on large hash
HSCAN large-hash 0 COUNT 100

# Instead of unbounded LRANGE
LRANGE list 0 99  # Limit!

# Instead of full ZRANGE
ZRANGE zset 0 99  # Limit!

Command Renaming (Block Dangerous Commands)

# In redis.conf
rename-command KEYS ""
rename-command FLUSHALL ""
rename-command FLUSHDB ""

# Or rename to something obscure
rename-command KEYS "INTERNAL_KEYS_a8f3b2c1"

Regular Review

Schedule weekly SLOWLOG review. Slow commands often creep in gradually - a new feature adds KEYS, a migration script runs SMEMBERS on growing sets. Catch them early.

9. CLI vs Redimo

CLI Output

1) 1) (integer) 14
   2) (integer) 1705312245
   3) (integer) 15234
   4) 1) "EVALSHA"
      2) "abc123def456789..."
      3) "3"
      4) "{user:1001}:profile"
      5) "{user:1001}:settings"
   5) "192.168.1.100:52345"
   6) "myapp"

# Hard to scan, compare, or filter

What Would Help

  • • Table view with sortable columns
  • • Human-readable timestamps
  • • Duration in ms instead of μs
  • • Filter by command type
  • • Trend visualization over time

Quick Reference

CommandPurpose
SLOWLOG GET [n]Get last n slow entries
SLOWLOG LENCount of log entries
SLOWLOG RESETClear the log
slowlog-log-slower-thanThreshold in microseconds
slowlog-max-lenMax entries to keep

Find Your Slow Commands

Performance issues hide in plain sight. SLOWLOG reveals them. Debug faster with Redimo.

Download Redimo - It's Free

Continue Learning

Free Download

Stop Fighting with CLI.
Visualize Your Data.

Redimo makes every Valkey and Redis command easier. Visual data, inline editing, Safe Mode for production.