慢查询指的是redis命令的执行时间,不包括网络传输和排队时间。

Redis配置文件redis.conf中描述慢查询相关的选项在SLOW LOG部分

################################## 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

也可以使用config get及config set来查询和修改,config rewrite可以写入配置文件。此外,slowlog命令还可以完成一些慢查询日志相关的其它操作。

# 命令执行超过多少微秒就记录慢查询日志(1秒=1000毫秒=1000000微秒)
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"
# 获取慢查询日志列表当前长度
127.0.0.1:6379> slowlog len
(integer) 0
# 获取慢查询
127.0.0.1:6379> slowlog get
# 重置慢查询
127.0.0.1:6379> slowlog reset
OK

一条慢查询日志包括4个属性:日志id命令执行的时间戳命令耗时命令和参数

Redis-09.慢查询的更多相关文章

  1. 浅谈Redis之慢查询日志

    首先我们需要知道redis的慢查询日志有什么用?日常在使用redis的时候为什么要用慢查询日志? 第一个问题: 慢查询日志是为了记录执行时间超过给定时长的redis命令请求 第二个问题: 让使用者更好 ...

  2. redis设置慢查询日志

    Redis 的慢查询日志功能用于记录执行时间超过给定时长的命令请求, 用户可以通过这个功能产生的日志来监视和优化查询速度. 1.redis生命周期 慢查询发生在第3阶段 2.两个配置 2.1.slow ...

  3. 在nodejs使用Redis缓存和查询数据及Session持久化(Express)

    在nodejs使用Redis缓存和查询数据及Session持久化(Express) https://segmentfault.com/a/1190000002488971

  4. Redis慢日志查询

    Redis slowlog 是个什么 redis的slow log记录了那些执行时间超过规定时长的请求.执行时间不包括I/O操作(比如与客户端进行网络通信等),只是命令的实际执行时间(期间线程会被阻塞 ...

  5. 使用 Redis 如何实现查询附近的人?「视频版」——面试突击 003 期

    面试问题 Redis 如何实现查询附近的人? 涉及知识点 Redis 中如何操作位置信息? GEO 底层是如何实现的? 如何在程序实现查询附近的人? 在实际使用中需要注意哪些问题? 视频答案 视频地址 ...

  6. 为什么 Redis 的查询很快, Redis 如何保证查询的高效

    Redis 如何保证高效的查询效率 为什么 Redis 比较快 Redis 中的数据结构 1.简单动态字符串 SDS 对比 c 字符串的优势 SDS可以常数级别获取字符串的长度 杜绝缓冲区溢出 减少修 ...

  7. [转]在nodejs使用Redis缓存和查询数据及Session持久化(Express)

    本文转自:https://blog.csdn.net/wellway/article/details/76176760 在之前的这篇文章 在ExpressJS(NodeJS)中设置二级域名跨域共享Co ...

  8. Redis Geo: Redis新增位置查询功能

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/144.html 移动互联网增进了人与人之间的联系,其中基于位置信息的服务( ...

  9. Redis 存储、查询

    [TOC] 数据存储 假设我们在MySQL数据库中有这样一张表: mysql> desc user_info; Field Type Null Key Default Extra id int( ...

  10. 转:Redis Geo: Redis新增位置查询功能

    原文来自于:http://www.infoq.com/cn/news/2015/07/redis-geo 移动互联网增进了人与人之间的联系,其中基于位置信息的服务(Location Based Ser ...

随机推荐

  1. 微信小程序开发——点击防重的解决方案

    对于一些涉及后端接口请求的单击事件,不论后端是否做了请求限制,前端还是有必要进行点击防重处理的. 这样既能减少对服务器端的压力,也能有效防止因重复请求而造成一些不可预期的异常. 尤其是接口请求结果处理 ...

  2. 生成器函数yield

    先看一个栗子: # -*- coding:UTF-8 -*- __autor__ = 'zhouli' __date__ = '2018/12/6 21:08' # 生成器函数,函数里只要有yield ...

  3. System program tools

    program 描述     RSBDCOS0 执行 OS 命令 (已登录在 SYSLOG 和跟踪文件中)                            

  4. Oracle lag()/lead() over()分析函数

    with tmp as(select '1' id ,'aa' name ,'22' age from dual union allselect '2' id ,'bb' name ,'20' age ...

  5. zabbix的api接口

    zabbix官方文档解释,api是开发者能获得修改zabbix配置,获取历史数据.主要用于: 1.创建新应用 2.集成zabbix与第三方软件 3.自动运行任务 运用JSON-RPC2.0协议,因此接 ...

  6. 机器学习之支持向量机(SVM)学习笔记

    支持向量机是一种二分类算法,算法目的是找到一个最佳超平面将属于不同种类的数据分隔开.当有新数据输入时,判断该数据在超平面的哪一侧,继而决定其类别. 具体实现思路: 训练过程即找到最佳的分隔超平面的过程 ...

  7. CentOS 7 minimal网络配置

    centos最小化安装没有ifconfig命令,可以使用  ip addr  查看网络信息,习惯ifconfig的用户,则使用 yum -y install net-tools 即可 ; 如果yum不 ...

  8. 利用css实现带有省略号的段落

    带有省略号的段落就是你只能在一行显示一段文字,文字过长是肯定不能完全显示的,如果默认的话,超出的文字会自动换行,撑大盒子. 1.这时需要设置white-space: nowrap,禁止换行.这样的话, ...

  9. impala操作hase、hive

    impala中使用复杂类型(Hive):    如果Hive中创建的表带有复杂类型(array,struct,map),且储存格式(stored as textfile)为text或者默认,那么在im ...

  10. centos 安装nvm和node.js

    #安装githubyum install git -y #下载nvmgit clone git://github.com/creationix/nvm.git ~/nvm #设置nvm 自动运行;ec ...