# LATENCY HISTOGRAM

> Return the latency distribution of each command as cumulative power-of-two buckets.

URL: https://docs.hotkv.com/commands/latency-histogram/

```
LATENCY HISTOGRAM [command [command ...]]
```

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

`LATENCY HISTOGRAM` returns how long each command has taken, as a histogram.
Name commands (case-insensitive, with subcommands written as
`config|get`) to get only those, or name none to get every command that has
run. Commands that have not run since the start or the last
[CONFIG RESETSTAT](https://docs.hotkv.com/commands/config-resetstat/index.md), and unknown names, are left
out. The data is collected while `latency-tracking` is `yes`, the default.

Buckets are powers of two microseconds (1, 2, 4, 8, ...). Each bucket's count
is cumulative: the number of calls that took at most that long. Only buckets
where the count grows are listed.

## Return value

A map from command name to a map with two fields, in RESP3; nested flat
arrays of name and value pairs in RESP2:

| Field | Value |
| --- | --- |
| `calls` | Number of calls measured. |
| `histogram_usec` | Map from bucket upper bound (microseconds) to cumulative call count. |

## Examples

```
127.0.0.1:6379> LATENCY HISTOGRAM get set
1) "get"
2) 1) "calls"
   2) (integer) 15020
   3) "histogram_usec"
   4) 1) (integer) 2
      2) (integer) 12650
      3) (integer) 4
      4) (integer) 14995
      5) (integer) 16
      6) (integer) 15020
3) "set"
4) 1) "calls"
   2) (integer) 300
   3) "histogram_usec"
   4) 1) (integer) 4
      2) (integer) 298
      3) (integer) 8
      4) (integer) 300
```

## Compatibility

Same reply shape as Redis 7 and Valkey 8.

## See also

[INFO](https://docs.hotkv.com/commands/info/index.md) (`latencystats` and `commandstats`),
[LATENCY](https://docs.hotkv.com/commands/latency/index.md), [CONFIG RESETSTAT](https://docs.hotkv.com/commands/config-resetstat/index.md)