当前位置:网站首页>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
边栏推荐
- Map接口的注意事项
- Redis学习笔记—单个键管理
- Flink error --caused by: org apache. calcite. sql. parser. SqlParseException: Encountered “time“
- Leetcode topic analysis count primes
- 多线程初学
- 披萨订购设计----简单工厂模式
- How to use "tomato working method" in flowus, notation and other note taking software?
- Redis学习笔记—数据库管理
- 瞄准海外宠物市场,「Grasphand 」做了一款独立于手机的智能追踪产品 | 早期项目
- GPIO初识
猜你喜欢

The fourth online workshop review

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

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

线性表(SequenceList)的顺序表示与实现----线性结构

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

GeoServer adding mongodb data source

986. Interval List Intersections

6月《中國數據庫行業分析報告》發布!智能風起,列存更生

The sliding window of the force button "step by step" (209. sub array with the smallest length, 904. fruit basket)
Redis学习笔记—Redis与Lua
随机推荐
New engine, new capability, new experience, Tencent host security flagship release
在小程序中实现视频通话及互动直播的一种方法
12个球,有一个与其他不一样,提供一个天平,三次找出来
【活动报名】SOFAStack × CSDN 联合举办开源系列 Meetup ,6 月 24 日火热开启
文件的打开新建与存储
Map接口的注意事项
125. Valid Palindrome
MySQL故障案例 | mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME
Redis学习笔记—Pipeline
The sliding window of the force button "step by step" (209. sub array with the smallest length, 904. fruit basket)
ionic5錶單輸入框和單選按鈕
三层架构与SSM之间的对应关系
670. Maximum Swap
Redis学习笔记—事务
Redis学习笔记—主从复制
297. Serialize and Deserialize Binary Tree
node request模块cookie使用
Structure binary tree from preorder and inorder traversal for leetcode topic analysis
A method of realizing video call and interactive live broadcast in small programs
如何在 FlowUs、Notion 等笔记软件中使用矩阵分析法建立你的思维脚手架