当前位置:网站首页>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
边栏推荐
- 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
- Batch generation of code128- C barcode
- 528. Random Pick with Weight
- 2022.6.22-----leetcode.513
- Vue3表单页面利用keep-alive缓存数据的一种思路
- 670. Maximum Swap
- June 22, 2022: golang multiple choice question, what does the following golang code output? A:3; B:1; C:4; D: Compilation failed.
- '教练,我想打篮球!' —— 给做系统的同学们准备的 AI 学习系列小册
- Use of type dependent names must be prefixed with 'typename'
- Custom tags - JSP tag enhancements
猜你喜欢

自定义标签——jsp标签基础
![[cloud native | kubernetes] kubernetes principle and installation (II)](/img/db/dd93bbcac6d0404d44f67d2da12880.png)
[cloud native | kubernetes] kubernetes principle and installation (II)

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

"Coach, I want to play basketball" -- AI Learning Series booklet for students who are making systems

一个采用直接映射方式的32KB缓存......存储器课后习题

披萨订购设计----简单工厂模式

Custom tag - JSP tag Foundation

986. Interval List Intersections

【学习资源】理解数学和热爱数学

Flink错误--Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered “time“
随机推荐
扫码登录基本流程
523. Continuous Subarray Sum
在小程序中实现视频通话及互动直播的一种方法
3、 System analysis and design
4、 Database design
2022.6.22-----leetcode.513
ucosii(学习笔记)
What exactly is RT?
点击添加下拉框
Redis学习笔记—redis-benchmark详解
Intelligent operation and maintenance exploration | anomaly detection method in cloud system
Structure binary tree from inorder and postorder traversal for leetcode topic analysis
Isomorphic strings for leetcode topic resolution
An idea of using keep alive to cache data in vue3 form pages
Quartz Crystal Drive Level Calculation
Use of type dependent names must be prefixed with 'typename'
1、 Software architecture evaluation
General paging (1)
js 用**遮罩身份证以及手机号的重要数据
Quartz Crystal Drive Level Calculation