{
  "id": "redis-slow-log",
  "title": "View and manage Redis slow log",
  "url": "https://redis.io/docs/latest/operate/rs/7.8/clusters/logging/redis-slow-log/",
  "summary": "",
  "content": "\n[Redis slow log]() is one of the best\ntools for debugging and tracing your Redis database, especially if you\nexperience high latency and high CPU usage with Redis operations.\nBecause Redis is based on a single threaded architecture, Redis slow log\ncan be much more useful than slow log mechanisms of multi-threaded\ndatabase systems such as MySQL slow query log.\n\nUnlike tools that introduce lock overhead, which complicates the debugging\nprocess, Redis slow log is highly effective at showing the actual processing time of each command.\n\n## Redis Software slow log enhancements \n\nRedis Software includes enhancements to the standard Redis\nslow log capabilities that allow you to analyze the execution time\ncomplexity of each command. This enhancement can help you better analyze\nRedis operations, allowing you to compare the differences between\nexecution times of the same command, observe spikes in CPU usage, and\nmore.\n\nThis is especially useful with complex commands such as\n[ZUNIONSTORE](),\n[ZINTERSTORE](), and\n[ZRANGEBYSCORE]().\n\nThe enhanced Redis Software slow log adds the **Complexity info** field to the\noutput data.\n\nView the complexity info data by its respective command in the table\nbelow:\n\n| Command | Value of interest | Complexity |\n|------------|-----------------|-----------------|\n| LINSERT | N - list len | O(N) |\n| LREM | N - list len | O(N) |\n| LTRIM | N - number of removed elements | O(N) |\n| PUBLISH | N - number of channel subscribers\u003c/br\u003eM - number of subscribed patterns | O(N+M) |\n| PSUBSCRIBE | N - number of patterns client is subscribed to\u003c/br\u003eargc - number of arguments passed to the command | O(argc\\*N) |\n| PUNSUBSCRIBE | N - number of patterns client is subscribed to\u003c/br\u003eM - total number of subscribed patterns\u003c/br\u003eargc - number of arguments passed to the command | O(argc\\*(N+M)) |\n| SDIFF | N - total number of elements in all sets | O(N) |\n| SDIFFSTORE | N - total number of elements in all sets | O(N) |\n| SINTER                | N - number of elements in smallest set\u003c/br\u003eargc - number of arguments passed to the command | O(argc\\*N) |\n| SINTERSTORE           | N - number of elements in smallest set\u003c/br\u003eargc - number of arguments passed to the command | O(argc\\*N) |\n| SMEMBERS              | N - number of elements in a set | O(N) |\n| SORT                  | N - number of elements in the when no sorting list/set/zset\u003c/br\u003eM - number of elements in result | O(N+M\\*log(M))O(N) |\n| SUNION                | N - number of elements in all sets | O(N) |\n| SUNIONSTORE           | N - number of elements in all sets | O(N) |\n| UNSUBSCRIBE           | N - total number of clients subscribed to all channels | O(N) |\n| ZADD                  | N - number of elements in the zset | O(log(N)) |\n| ZCOUNT                | N - number of elements in the zset\u003c/br\u003eM - number of elements between min and max | O(log(N)+M) |\n| ZINCRBY               | N - number of elements in the zset | O(log(N)) |\n| ZINTERSTORE           | N – number of elements in the smallest zset\u003c/br\u003eK – number of zsets\u003c/br\u003eM – number of elements in the results set | O(N\\*K)+O(M\\*log(M)) |\n| ZRANGE                | N – number of elements in the zset\u003c/br\u003eM – number of results | O(log(N)+M) |\n| ZRANGEBYSCORE         | N – number of elements in the zset\u003c/br\u003eM – number of results | O(log(N)+M) |\n| ZRANK                 | N – number of elements in the zset | O(log(N)) |\n| ZREM                  | N – number of elements in the zset\u003c/br\u003eargc – number of arguments passed to the command | O(argc\\*log(N)) |\n| ZREMRANGEBYRANK       | N – number of elements in the zset\u003c/br\u003eargc – number of arguments passed to the command | O(log(N)+M) |\n| ZREMRANGEBYSCORE      | N – number of elements in the zset\u003c/br\u003eM – number of elements removed | O(log(N)+M) |\n| ZREVRANGE             | N – number of elements in the zset\u003c/br\u003eM – number of results | O(log(N)+M) |\n| ZREVRANK              | N – number of elements in the zset | O(log(N)) |\n| ZUNIONSTORE           | N – sum of element counts of all zsets\u003c/br\u003eM – element count of result | O(N)+O(M\\*log(M)) |\n\n## View slow log\n\nTo view slow log entries for Redis Software databases, use one of the following methods:\n\n- Cluster Manager UI:\n\n    1. To access the slow log in the Cluster Manager UI, your [cluster management role]() must be Admin, Cluster Member, or DB Member.\n    \n    1. Select a database from the **Databases** list.\n\n    1. On the database's **Configuration** screen, select the **Slowlog** tab.\n\n- Command line:\n\n    Use [`redis-cli`]() to run [`SLOWLOG GET`]():\n\n    ```sh\n    redis-cli -h \u003cendpoint\u003e -p \u003cport\u003e SLOWLOG GET \u003ccount\u003e\n    ```\n\n## Change slow log threshold\n\nThe slow log includes all database commands that take longer than ten milliseconds (10,000 microseconds) by default. You can use [`redis-cli`]() to view or change this threshold.\n\nTo check the current threshold, run [`CONFIG GET`]():\n\n```sh\nredis-cli -h \u003cendpoint\u003e -p \u003cport\u003e CONFIG GET slowlog-log-slower-than\n```\n\nTo change the threshold, run [`CONFIG SET`]():\n\n```sh\nredis-cli -h \u003cendpoint\u003e -p \u003cport\u003e CONFIG SET slowlog-log-slower-than \u003cvalue_in_microseconds\u003e\n```\n\n## Change maximum entries\n\nThe slow log retains the last 128 entries by default. You can use [`redis-cli`]() to view or change the maximum number of entries.\n\nTo check the current maximum, run [`CONFIG GET`]():\n\n```sh\nredis-cli -h \u003cendpoint\u003e -p \u003cport\u003e CONFIG GET slowlog-max-len\n```\n\nTo change the maximum, run [`CONFIG SET`]():\n\n```sh\nredis-cli -h \u003cendpoint\u003e -p \u003cport\u003e CONFIG SET slowlog-max-len \u003cvalue\u003e\n```\n",
  "tags": ["docs","operate","rs"],
  "last_updated": "2026-04-01T08:10:08-05:00"
}

