当前位置:网站首页>Redis learning notes - slow query analysis
Redis learning notes - slow query analysis
2022-06-23 09:10:00 【Love Guoba】
Slow query logs help developers locate slow operations in the system , Slow query is the execution time of each command calculated by the system before and after the command execution , When the preset threshold is exceeded , This command will be the relevant information ( for example : Time of occurrence , Time consuming , Command details ) recorded ,Redis Provides similar functionality
The four execution steps of the client request
1. dispatch orders ——2. Queued for execution ——3. Carry out orders ——4. Return results
Slow query only counts steps 3 This step of executing the command , Therefore, no slow query does not mean that the client does not timeout
Configuration parameters for slow queries
stay redis.conf There are two configuration items in the configuration file :slowlog-log-slower-than and slowlog-max-len
slowlog-log-slower-than Indicates a preset threshold , The default is 10000 Microsecond (1 second =1000 millisecond =1000000 Microsecond ), If a command takes longer than 10000 Microseconds will be recorded in the slow query log
If slowlog-log-slower-than Set to 0 All the commands will be recorded , Set to less than 0 No command will be recorded
slowlog-max-len:Redis A list is used to store slow query logs , This configuration is the maximum length of the list , The default is 128 strip , If more than 128 The first inserted data will be deleted
If you want to modify the configuration, you can directly go to redis Modify the client , With slowlog-max-len For example
127.0.0.1:6379> config set slowlog-max-len 512
OK
127.0.0.1:6379> config rewrite
OK
When viewing the configuration file , Find out slowlog-max-len The configuration has been modified to 512 了
Get slow query log
Although the slow query log is stored in Redis In the memory list , however Redis There are no keys to expose this list , But through a set of commands to achieve the slow query log access and management .
slowlog get [n]
Query two slow query records , Here [n] It is optional , If you do not fill in all the , If you fill in, you will query the specified number of items
127.0.0.1:6379> slowlog get "2"
1) 1) (integer) 12
2) (integer) 1552899968
3) (integer) 1000502
4) 1) "migrate"
2) "127.0.0.1"
3) "6379"
4) "a"
5) "1"
6) "1000"
7) "copy"
5) "127.0.0.1:35730"
6) ""
2) 1) (integer) 11
2) (integer) 1552899943
3) (integer) 1000909
4) 1) "migrate"
2) "127.0.0.1"
3) "6379"
4) "a"
5) "0"
6) "1000"
7) "copy"
5) "127.0.0.1:35730"
6) ""
Four main parameters
- Slow query log identification id
- Occurrence timestamp
- The command takes time
- Execute commands and parameters
Get the length of the slow query list
slowlog len
The current is 13 Slow query
127.0.0.1:6379> slowlog len
(integer) 13
Clear slow query list
slowlog reset
Clear the current slow query list
127.0.0.1:6379> slowlog len
(integer) 13
127.0.0.1:6379> slowlog reset
OK
127.0.0.1:6379> slowlog len
(integer) 0
边栏推荐
猜你喜欢

297. Serialize and Deserialize Binary Tree
Redis学习笔记—数据类型:字符串(string)
Redis学习笔记—Pipeline

力扣之滑动窗口《循序渐进》(209.长度最小的子数组、904. 水果成篮)

自定义标签——jsp标签基础

通用分页(1)

js 用**遮罩身份证以及手机号的重要数据

瞄准海外宠物市场,「Grasphand 」做了一款独立于手机的智能追踪产品 | 早期项目

'coach, I want to play basketball!'—— AI Learning Series booklet for system students

“教练,我想打篮球“ —— 给做系统的同学们准备的 AI 学习系列小册
随机推荐
Servlet-02 生命周期
【云原生 | Kubernetes篇】Kubernetes原理与安装(二)
Redis学习笔记—遍历键
Jog运动模式
Aiming at the overseas pet market, "grasshand" has developed an intelligent tracking product independent of mobile phones | early project
JSP入门总结
[qnx hypervisor 2.2 user manual]6.2 network
Redis学习笔记—单个键管理
36 krypton launched | cloud native database company "tuoshupai" completed a new round of strategic financing, and the valuation has reached the level of quasi Unicorn
类型从属名称的使用必须以“typename”为前缀
Unity grid programming 08
4、 Database design
36氪首发|云原生数据库公司「拓数派」完成新一轮战略融资,估值已达准独角兽级别
设CPU有16根地址线,8根数据线,并用MREQ作为访存控制线号......存储器与CPU的连接
Redis学习笔记—主从复制
Leetcode topic analysis count primes
New engine, new capability, new experience, Tencent host security flagship release
The sliding window of the force button "step by step" (209. sub array with the smallest length, 904. fruit basket)
Learn SCI thesis drawing skills (E)
社区文章|MOSN 构建 Subset 优化思路分享