redis统计大key

Posted Oops!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis统计大key相关的知识,希望对你有一定的参考价值。

–bigkeys

redis-cli -h <host> -p <port> -n <db> --bigkeys

这条命令会从指定的 Redis DB 中持续采样,实时输出当时得到的 value 占用空间最大的 key 值,并在最后给出各种数据结构的 biggest key 的总结报告:

user $ redis-cli -h myhost -p 12345 --bigkeys

# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).

[00.00%] Biggest hash   found so far ‘idx:同类项‘ with 1 fields
[00.00%] Biggest hash   found so far ‘idx:格点‘ with 3 fields
[00.00%] Biggest hash   found so far ‘idx:任意‘ with 14 fields
[02.29%] Biggest hash   found so far ‘idx:设‘ with 16 fields
[02.29%] Biggest hash   found so far ‘idx:4‘ with 69 fields
[04.45%] Biggest set    found so far ‘indexed_word_set‘ with 1482 members
[05.93%] Biggest hash   found so far ‘idx:c‘ with 159 fields
[11.79%] Biggest hash   found so far ‘idx:的‘ with 196 fields

-------- summary -------

Sampled 1484 keys in the keyspace!
Total key length in bytes is 13488 (avg len 9.09)

Biggest    set found ‘indexed_word_set‘ has 1482 members
Biggest   hash found ‘idx:的‘ has 196 fields

0 strings with 0 bytes (00.00% of keys, avg size 0.00)
0 lists with 0 items (00.00% of keys, avg size 0.00)
2 sets with 1710 members (00.13% of keys, avg size 855.00)
1482 hashs with 6731 fields (99.87% of keys, avg size 4.54)
0 zsets with 0 members (00.00% of keys, avg size 0.00)

这条命令给出的 "big key" ,是值得去分析一下的。

以上是关于redis统计大key的主要内容,如果未能解决你的问题,请参考以下文章

Redis第五篇——大key和热key问题

Redis第五篇——大key和热key问题

统计redis中key的数量

redis统计某个开头key的数量

给你一个亿的keys,Redis如何统计?

redis那个命令可以统计key的数量?