慢查询指的是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. ReentrantLock 实现

    ReentrantLock 实现:   关于锁的操作都是依赖于state 的值,当state =0 时候,表示 线程可以获取锁,state =1 表示锁已经占用,等待释放 获取锁的方法: protec ...

  2. webpack简笔(1)

    1.npm init -> 生成package.json文件 2.npm install webpack --save-dev (不建议全局安装 ,会锁定版本) [ --save-dev 开发环 ...

  3. Microsoft SQL Server 错误:948

    版本655指的是SQL2008, 版本611指的是SQL2005, (还有一个版本539指的是SQL2000) 楼主的情况属于典型的从高版本降低至低版本使用的情景. 按微软的官方说法, 是不支持从高版 ...

  4. Tomcat服务相关配置

    安装服务: 进入安装目录-> bin ,在空白处按住shift+鼠标右键 ->在此处运行DOS命令窗口,将service.bat文件拖拽到命令窗口中,按enter键运行, 出现了“Usag ...

  5. 第一个spring简单的helloworld

    spring 是一个开源的框架 也是轻量级框架 1.导入jar包 spring的版本 4.0 目录: spring-framework-4.0.0.RELEASE-libs 下的jar  spring ...

  6. abap 常用TCODE

    ABAP: 通过查询表TSTC或者TSTCT:SAP系统将所有的事务代码都存储在这个表中,包括字开发的Y*和Z* TCODE 事务代码功能描述 CG3Y 下载服务器上文件 CG3Z upload fi ...

  7. java8 LocalDateTime转unix时间戳(带毫秒,不带毫秒)

    转载自:LocalDateTime To Timestamp Epoch Seconds And Milliseconds Convert LocalDateTime to seconds since ...

  8. tmux使用(程序员适用)

    原文:http://jack-boy.iteye.com/blog/1586908 tmux基本使用     tmux是一个优秀的终端复用软件,即使非正常掉线,也能保证当前的任务运行,这一点对于远程S ...

  9. Eclipse 中 Maven 项目默认JDK版本为1.5 的解决方法

    在 Eclipse 中 Maven project 的默认 JDK 版本是 1.5, 如果不在 settings.xml 或者 pom.xml 中显示的指出 JDK 版本,每次 右键项目--> ...

  10. dubbo入门学习 五 provider端的编写

    1. 新建Maven Project, 里面只有接口(dubbo-service) 1.1 为什么这么做? RPC框架,不希望Consumer知道具体实现.如果实现类和接口在同一个项目中,Consum ...