# HOTKEYS

> List the most frequently accessed keys, or clear the access counts.

URL: https://docs.hotkv.com/commands/hotkeys/

```
HOTKEYS TOP [count]
HOTKEYS RESET
```

- Group: Server
- Complexity: O(N) where N is the number of keys tracked
- HotKV Cloud: all plans
- On-Premise: no license needed

`HOTKEYS` shows which keys are accessed most, without scanning the keyspace
or sampling traffic yourself. Use it to find keys that concentrate load on
one node, or candidates for local caching. See [hot keys](https://docs.hotkv.com/develop/hot-keys/index.md)
for ways to deal with them.

Tracking is off by default. Turn it on with `hotkey-tracking yes`, in the
config file or with [CONFIG SET](https://docs.hotkv.com/commands/config-set/index.md). While it is on, each
command that takes keys counts one access for its first key. The counts are
approximate.

## Subcommands

| Subcommand | Effect |
| --- | --- |
| `TOP [count]` | The `count` keys with the highest counts, highest first. `count` defaults to 10. |
| `RESET` | Forget all counts. |

## Return value

| Case | Reply (RESP2 and RESP3) |
| --- | --- |
| `TOP` | An array of `[key, count]` pairs (bulk string and integer). Empty while tracking is off or nothing has been counted. |
| `RESET` | Simple string `OK` |
| `count` is negative or not an integer | Error `ERR value is not an integer or out of range` |
| Unknown subcommand | Error `ERR unknown subcommand '<name>'. Try HOTKEYS TOP [count], HOTKEYS RESET.` |

## Examples

```
127.0.0.1:6379> CONFIG SET hotkey-tracking yes
OK
127.0.0.1:6379> HOTKEYS TOP 3
1) 1) "product:1001"
   2) (integer) 48210
2) 1) "session:9f2c"
   2) (integer) 12077
3) 1) "rate:api:203.0.113.7"
   2) (integer) 9954
127.0.0.1:6379> HOTKEYS RESET
OK
```

## Compatibility

HotKV-only command: Redis 7 and Valkey 8 have no `HOTKEYS`. (Newer Redis
versions add a `HOTKEYS` command with different subcommands, which HotKV
does not implement.) In Redis, `redis-cli --hotkeys` scans the keyspace
instead.

## See also

[OBJECT FREQ](https://docs.hotkv.com/commands/object-freq/index.md), [MONITOR](https://docs.hotkv.com/commands/monitor/index.md),
[hot keys](https://docs.hotkv.com/develop/hot-keys/index.md)