# PFDEBUG

> Inspect or convert the representation of a HyperLogLog.

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

```
PFDEBUG GETREG key
PFDEBUG DECODE key
PFDEBUG ENCODING key
PFDEBUG TODENSE key
```

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

`PFDEBUG` is a diagnostic command for HyperLogLog values. A HyperLogLog starts
in a compact `sparse` representation and switches to the fixed-size `dense`
one as it fills up (the switch point is set with `hll-sparse-max-bytes`).
`PFDEBUG` lets you see which one a key uses and its raw registers. It is an
administrative command, meant for debugging rather than application code.

## Options

| Subcommand | Effect |
| --- | --- |
| `GETREG` | Return the value of every register. Converts a sparse HyperLogLog to dense first. |
| `DECODE` | Return a text description of a sparse HyperLogLog's contents. |
| `ENCODING` | Return `sparse` or `dense`. |
| `TODENSE` | Convert to dense if the HyperLogLog is sparse. |

The subcommand comes before the key and is not case-sensitive.

## Return value

| Subcommand | RESP2 | RESP3 |
| --- | --- | --- |
| `GETREG` | Array of 16384 integers | Array |
| `DECODE` | Bulk string | Bulk string |
| `ENCODING` | Simple string `sparse` or `dense` | Simple string |
| `TODENSE` | Integer `1` if it was converted, `0` if it was already dense | Integer |

Errors:

- `ERR The specified key does not exist` for a missing key.
- `ERR HLL encoding is not sparse` for `DECODE` on a dense HyperLogLog.
- `ERR Unknown PFDEBUG subcommand '<name>'` for an unknown subcommand.
- The `WRONGTYPE` and `INVALIDOBJ` errors of [PFADD](https://docs.hotkv.com/commands/pfadd/index.md).

## Examples

```
127.0.0.1:6379> PFADD visitors alice bob carol
(integer) 1
127.0.0.1:6379> PFDEBUG ENCODING visitors
sparse
127.0.0.1:6379> PFDEBUG TODENSE visitors
(integer) 1
127.0.0.1:6379> PFDEBUG ENCODING visitors
dense
127.0.0.1:6379> PFCOUNT visitors
(integer) 3
```

## Compatibility

Same subcommands and replies as Redis 7 and Valkey 8.

## See also

[PFSELFTEST](https://docs.hotkv.com/commands/pfselftest/index.md), [PFADD](https://docs.hotkv.com/commands/pfadd/index.md),
[PFCOUNT](https://docs.hotkv.com/commands/pfcount/index.md)