In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Redis in how to achieve slow query operation, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
What is slow query?
Like mysql's slow SQL log analysis, redis has similar features to help locate some slow query operations.
Redis slowlog is a logging system used by Redis to record the execution time of queries.
Query execution time refers to the time it takes to execute a query command, excluding IO operations such as client response (talking) and sending replies.
In addition, slow log is stored in memory and reads and writes very fast, so you can safely use it without having to worry about harming the speed of Redis by turning on slow log.
Slow query parameters
First, let's take a look at the two parameters corresponding to the slow log analysis:
1. Slowlog-log-slower-than: the default threshold is 10000 microseconds, that is, 10 milliseconds, for how long a record is recorded.
2. Slowlog-max-len: record the number of slow queries. Default is 128.When the number of entries exceeds the set number, the earliest entry into the queue will be removed. It is recommended online to increase the value, such as 1000, to reduce the frequency of queue removal.
127.0.0.1 config get slowlog-max-len 6379 > config get slowlog-log-slower-than 1) "slowlog-log-slower-than" 2) "10000" 127.0.1 config get slowlog-max-len 1) "slowlog-max-len" 2) "128"
You can adjust these two parameters with config set, or set them in a configuration file.
# # SLOW LOG # The Redis Slow Log is a system to log queries that exceeded a specified # execution time. The execution time does not include the O operations # like talking with the client, sending the reply and so forth, # but just the time needed to actually execute the command (this is the only # stage of command execution where the thread is blocked and can not serve # other requests in the meantime). # # You can configure the slow log with two parameters: one tells Redis # what is the execution time, in microseconds, to exceed in order for the # command to get logged, and the other parameter is the length of the # slow log. When a new command is logged the oldest one is removed from the # queue of logged commands. # The following time is expressed in microseconds, so 1000000 is equivalent # to one second. Note that a negative number disables the slow log, while # a value of zero forces the logging of every command. Slowlog-log-slower-than 10000 # There is no limit to this length. Just be aware that it will consume memory. # You can reclaim memory used by the slow log with SLOWLOG RESET. Slowlog-max-len 128 slow query command
Syntax: slowlog subcommand [argument]
For example, perform slow query, obtain the number of slow query records, reset the slow query log, and so on:
192.168.10.38 slowlog get 9001 > empty list or set) 192.168.10.38 slowlog len 9001 > empty list or set 10 (192.168.10.38) 9001 > slowlog len (integer) 0192.168.10.38 slowlog len 9001 > is it helpful for you to read the contents mentioned above? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.