什么是慢查询
慢查询的作用:通过慢查询分析,找到有问题的命令进行优化。
和mysql的慢SQL日志分析一样,redis也有类似的功能,来帮助定位一些慢查询操作。
Redis slowlog是Redis用来记录查询执行时间的日志系统。
查询执行时间指的是不包括像客户端响应(talking)、发送回复等IO操作,而单单是执行一个查询命令所耗费的时间。
另外,slow log保存在内存里面,读写速度非常快,因此你可以放心地使用它,不必担心因为开启slow log而损害Redis的速度。
慢查询日志四个属性:
1、第一个字段是每个慢查询唯一标识。
2、处理完命令后的时间戳
3、执行改名了所需要的时间,单位微妙
4、命令的参数列表,是个数组类型
每个慢查询实体的ID都是唯一的,而且不会被重新设置,只会在redis重启后才会重置它.
慢查询参数
首先来关注下慢日志分析对应的两个参数:
1、slowlog-log-slower-than:预设阀值,即记录超过多少时间的记录,默认为10000微秒,即10毫秒。
2、slowlog-max-len:记录慢查询的条数,默认为128条,当超过设置的条数时最早进入队列的将被移除。线上建议增大数值,如:1000,这样可减少队列移除的频率。
127.0.0.1:6379> config get slowlog-log-slower-than 1) "slowlog-log-slower-than" 2) "10000" 127.0.0.1:6379> config get slowlog-max-len 1) "slowlog-max-len" 2) "128"
可以用config set对这两个参数进行调整,或者在配置文件中设置。
################################## 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 I/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
慢查询命令
语法:slowlog subcommand [argument]
如,进行查询慢查询、获取慢查询记录的数量、重置慢查询日志等操作:
192.168.10.38:9001> slowlog get (empty list or set) 192.168.10.38:9001> slowlog get 10 (empty list or set) 192.168.10.38:9001> slowlog len (integer) 0 192.168.10.38:9001> slowlog reset OK
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对的支持。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
- 崩坏星穹铁道2.2托帕培养材料大全 崩铁托帕养成材料清单一览
- 《M工业》基础攻略 简述+配置+下载
- 《百慕大野兽》基础攻略 简述+配置+下载
- 《披萨塔,Pizza Tower》基础攻略 简述+配置+下载
- 中唱唱片群星《好歌珍藏-母爱·亲情》2CD[WAV+CUE]
- 中唱唱片群星《好歌珍藏-大地飞歌》2CD[WAV]
- 金海心-那么骄傲[WAV]
- 数毛社分析PS5 Pro规格:GPU主频高达2.35GHz
- 《死侍3》新正片片段:狼叔被死侍硫酸脸恶心到了
- 《地狱潜者2》CEO赞扬社区玩家:你们的意志与合作力让我印象深刻
- 张学友 歌神《等风雨经过3CD》[WAV+CUE][2GB]
- 华语流行《周杰伦 2022最伟大的作品》[FLAC/分轨][1.7GB]
- 孙燕姿《No. 13作品 跳舞的梵谷》[WAV+CUE][400MB]
- 张心柔.2012-吟游诗人【禾广娱乐】【FLAC分轨】
- 关淑怡.1991-恋一世的爱【宝丽金】【WAV+CUE】