tools/bigkey_analyzer/README_en.md
A big key analysis tool for analyzing large keys in PikiwiDB instances. This tool is designed for the new storage structure in the unstable branch and supports multiple directory structures:
Run the following commands from the PikiwiDB root directory:
mkdir -p build
cd build
cmake ..
make bigkey_analyzer
After compilation, the executable will be generated in the build directory.
Usage: bigkey_analyzer [OPTIONS] <db_path>
Options:
--min-size=SIZE Only show keys larger than SIZE bytes
--top=N Only show top N largest keys
--prefix-stat Show statistics by key prefix
--prefix-delimiter=C Character used to delimit prefix (default: ':')
--type=TYPE Only analyze specific type (strings|hashes|lists|sets|zsets|all)
--output=FILE Write output to file instead of stdout
--help Display this help message
# Single instance
./bigkey_analyzer /path/to/pikiwidb/data
# Multi-DB instance (db/0, db/1, db/2...)
./bigkey_analyzer /path/to/pikiwidb
./bigkey_analyzer --min-size=1048576 /path/to/pikiwidb/data
./bigkey_analyzer --top=10 /path/to/pikiwidb/data
./bigkey_analyzer --type=hashes /path/to/pikiwidb/data
./bigkey_analyzer --prefix-stat /path/to/pikiwidb/data
./bigkey_analyzer --output=result.txt /path/to/pikiwidb/data
The tool output consists of three sections:
--prefix-stat option is used)Example output:
===== Big Key Analysis =====
DB Partition Type Size Key TTL
db0 1 hash 1048576 user:profile:1001 -1
db0 2 zset 524288 ranking:global 3600
db1 0 string 262144 config:settings -1
...
===== Key Prefix Statistics =====
Prefix Count Total Size Avg Size
user 100 10485760 104857.6
ranking 50 2621440 52428.8
config 10 524288 52428.8
...
===== Summary =====
Total keys analyzed: 160
Keys by type:
hash: 50 keys, 25.0 MB total, 524288.0 bytes avg
zset: 30 keys, 15.0 MB total, 524288.0 bytes avg
string: 80 keys, 10.0 MB total, 131072.0 bytes avg