偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Redis如何分析慢查詢操作?

數(shù)據(jù)庫 其他數(shù)據(jù)庫 Redis
和mysql的慢SQL日志分析一樣,redis也有類似的功能,來幫助定位一些慢查詢操作。Redis slowlog是Redis用來記錄查詢執(zhí)行時間的日志系統(tǒng)。

Redis如何分析慢查詢操作?

什么是慢查詢

和mysql的慢SQL日志分析一樣,redis也有類似的功能,來幫助定位一些慢查詢操作。

Redis slowlog是Redis用來記錄查詢執(zhí)行時間的日志系統(tǒng)。

查詢執(zhí)行時間指的是不包括像客戶端響應(yīng)(talking)、發(fā)送回復(fù)等IO操作,而單單是執(zhí)行一個查詢命令所耗費的時間。

另外,slow log保存在內(nèi)存里面,讀寫速度非??欤虼四憧梢苑判牡厥褂盟?,不必擔心因為開啟slow log而損害Redis的速度。

慢查詢參數(shù)

首先來關(guān)注下慢日志分析對應(yīng)的兩個參數(shù):

1、slowlog-log-slower-than:預(yù)設(shè)閥值,即記錄超過多少時間的記錄,默認為10000微秒,即10毫秒。

2、slowlog-max-len:記錄慢查詢的條數(shù),默認為128條,當超過設(shè)置的條數(shù)時最早進入隊列的將被移除。線上建議增大數(shù)值,如:1000,這樣可減少隊列移除的頻率。 

  1. 127.0.0.1:6379> config get slowlog-log-slower-than  
  2. 1) "slowlog-log-slower-than"  
  3. 2) "10000"  
  4. 127.0.0.1:6379> config get slowlog-max-len  
  5. 1) "slowlog-max-len"  
  6. 2) "128"  

可以用config set對這兩個參數(shù)進行調(diào)整,或者在配置文件中設(shè)置。 

  1. ################################## SLOW LOG ###################################  
  2. # The Redis Slow Log is a system to log queries that exceeded a specified  
  3. # execution time. The execution time does not include the I/O operations  
  4. like talking with the client, sending the reply and so forth,  
  5. # but just the time needed to actually execute the command (this is the only  
  6. # stage of command execution where the thread is blocked and can not serve  
  7. # other requests in the meantime). 
  8.  
  9. # You can configure the slow log with two parameters: one tells Redis  
  10. # what is the execution timein microseconds, to exceed in order for the  
  11. # command to get logged, and the other parameter is the length of the  
  12. # slow log. When a new command is logged the oldest one is removed from the  
  13. # queue of logged commands.   
  14. # The following time is expressed in microseconds, so 1000000 is equivalent  
  15. to one second. Note that a negative number disables the slow log, while  
  16. # a value of zero forces the logging of every command.  
  17. slowlog-log-slower-than 10000   
  18. # There is no limit to this length. Just be aware that it will consume memory.  
  19. # You can reclaim memory used by the slow log with SLOWLOG RESET.  
  20. slowlog-max-len 128 

慢查詢命令

語法:slowlog subcommand [argument]

如,進行查詢慢查詢、獲取慢查詢記錄的數(shù)量、重置慢查詢?nèi)罩镜炔僮鳎?/p>

  1. 192.168.10.38:9001> slowlog get  
  2. (empty list or set 
  3. 192.168.10.38:9001> slowlog get 10  
  4. (empty list or set 
  5. 192.168.10.38:9001> slowlog len   
  6. (integer) 0  
  7. 192.168.10.38:9001> slowlog reset  
  8. OK   

 

責任編輯:龐桂玉 來源: Java技術(shù)棧
相關(guān)推薦

2022-03-22 10:52:02

Redis變慢服務(wù)器

2019-09-11 10:23:58

Redis性能存儲

2020-09-13 13:05:41

MySQL慢查詢數(shù)據(jù)

2021-04-07 10:38:43

MySQL數(shù)據(jù)庫命令

2023-11-30 15:37:37

MySQL數(shù)據(jù)庫

2018-10-12 16:45:10

MySQL查詢?nèi)罩?/a>數(shù)據(jù)庫

2010-06-02 13:46:19

MySQL慢查詢

2009-09-16 10:48:32

LINQ查詢操作

2019-09-18 08:06:08

Redis數(shù)據(jù)庫命令

2022-04-29 15:24:53

Redis存儲慢查詢

2023-10-16 23:12:02

Redis數(shù)據(jù)結(jié)構(gòu)

2017-04-01 19:00:25

MySQL慢查詢

2022-07-14 14:46:51

數(shù)據(jù)庫SQL系統(tǒng)設(shè)計

2024-09-14 14:18:43

2010-10-14 15:07:44

MySQL慢查詢

2024-06-03 10:10:01

2021-11-08 06:57:35

Redis架構(gòu)設(shè)計

2022-10-27 09:42:22

數(shù)據(jù)庫SQL

2009-02-27 08:56:30

IIS.Net原理分析

2018-08-20 10:40:09

Redis位圖操作
點贊
收藏

51CTO技術(shù)棧公眾號