# Nodetool toppartitions

**toppartitions** <keyspace> <table> <duration> - Samples cluster writes and reads and reports the most active partitions in a specified table and time frame.

**toppartitions**  [<–ks-filters ks>] [<–cf-filters tables>] [<-d duration>] [<-s|–capacity capacity>] [<-a|–samplers samplers>]

#### NOTE
The command needs to be run while there are writes and reads operations.

| Parameter   | Description                                                                                            |
|-------------|--------------------------------------------------------------------------------------------------------|
| keyspace    | The keyspace name                                                                                      |
| table       | The table name                                                                                         |
| duration    | The duration in milliseconds (requires a `-d` prefix)                                                  |
| ks-filters  | List of keyspaces                                                                                      |
| cf-filters  | List of Tables (Column Families)                                                                       |
| capacity    | The capacity of the sampler; higher values increase accuracy at the cost of memory (default 256 keys). |
| samplers    | The samplers to use; `WRITES`, `READS`, or both (default).                                             |

For example:

```shell
nodetool toppartitions nba team_roster 5000
```

Additional examples:

* listing the top partitions from *all* tables in *all* keyspaces `nodetool toppartitions`
* listing the top partitions for the last 1000 ms `nodetool toppartitions -d 1000`
* listing the top partitions from a list of tables `nodetool toppartitions --cf-filters ks:t,system:status`
* listing the top partitions from all tables from a list of keyspaces `nodetool toppartitions --ks-filters ks,system`
* combining lists of keyspaces and tables `nodetool toppartitions --ks-filters ks --cf-filters system:local`

Example output:

```shell
WRITES Sampler:
  Cardinality: ~5 (256 capacity)
  Top 10 partitions:
         Partition                Count       +/-
         Russell Westbrook         100         0
         Jermi Grant               25          0
         Victor Oladipo            17          0
         Andre Roberson            1           0
         Steven Adams              1           0

READS Sampler:
  Cardinality: ~5 (256 capacity)
  Top 10 partitions:
         Partition                Count       +/-
         Russell Westbrook         100         0
         Victor Oladipo            17          0
         Jermi Grant               12          0
         Andre Roberson            5           0
         Steven Adams              1           0
```

In this example, we can see that for the `Partition` with `Partition Key` “Russell Westbrook”, 100 writes and 100 read operations were done during the set duration.

For each of the samplers (WRITES and READS in this specific example), nodetool toppartitions reports:

* The cardinality of the sampled operations (number of unique operations in the sample set).
* The number of partitions in a specified table that had the most traffic in a specified time period.

## Output

| Parameter     | Description                                                                                   |
|---------------|-----------------------------------------------------------------------------------------------|
| Partition     | The Partition Key, prefixed by the Keyspace and table (ks:cf)                                 |
| Count         | The number of operations of the specified type that occurred during the specified time period |
| +/-           | The margin of error for the Count statistic                                                   |
| Write Count   | The total number of writes since last boot                                                    |
| Write Latency | The average read latency                                                                      |

To know which node hold the partition key use the nodetool [getendpoints](https://docs.scylladb.com/manual/master/operating-scylla/nodetool-commands/getendpoints.md) command.

If the margin of error column (+/-) approaches the Count column, the measurement is inaccurate. You can increase accuracy by specifying
the `--capacity` option.

For example:

```shell
nodetool getendpoints nba team_roster Russell Westbrook
```

Example output:

```shell
10.0.0.72
```

## Additional Information

* [Catching a Hot Partition](https://docs.scylladb.com/manual/master/using-scylla/tracing.md#tracing-catching-a-hot-partition) - Information on how to locate a hot partition
* [Nodetool Reference](https://docs.scylladb.com/manual/master/operating-scylla/nodetool.md)
