# CMS.INCRBY

> Increase the counts of one or more items in a Count-min sketch.

URL: https://docs.hotkv.com/commands/cms-incrby/

```
CMS.INCRBY key item increment [item increment ...]
```

- Group: Count-min sketch
- Complexity: O(n * depth), n being the items
- HotKV Cloud: all plans
- On-Premise: no license needed

`CMS.INCRBY` adds `increment` to the count of each `item` in the Count-min
sketch at `key`, and returns each item's estimated count afterwards. The
sketch must exist: create it with [CMS.INITBYDIM](https://docs.hotkv.com/commands/cms-initbydim/index.md)
or [CMS.INITBYPROB](https://docs.hotkv.com/commands/cms-initbyprob/index.md).

Increments must be whole numbers of 0 or more. All of them are checked before
anything is counted, so one bad increment changes nothing. Counts stop at
4294967295.

## Return value

An array with one integer per item: its estimated count after the increment.
The shape is the same in RESP2 and RESP3.

If an item's count would go past 4294967295, its element is the error
`CMS: INCRBY overflow` instead.

Error replies for the whole call:

- `CMS: key does not exist`
- `CMS: Cannot parse number` for an increment that is not an integer.
- `CMS: Number cannot be negative`
- `ERR wrong number of arguments for 'cms.incrby' command` for unpaired arguments.
- `WRONGTYPE` if the key holds another type.

## Examples

```
127.0.0.1:6379> CMS.INITBYDIM pageviews 2000 5
OK
127.0.0.1:6379> CMS.INCRBY pageviews /home 3 /pricing 1
1) (integer) 3
2) (integer) 1
127.0.0.1:6379> CMS.INCRBY pageviews /home 2
1) (integer) 5
127.0.0.1:6379> CMS.INCRBY pageviews /home -1
(error) CMS: Number cannot be negative
```

## Compatibility

Same as `CMS.INCRBY` in RedisBloom. HotKV checks every increment before
counting any, so a bad increment leaves the sketch unchanged.

## See also

[CMS.QUERY](https://docs.hotkv.com/commands/cms-query/index.md), [CMS.INITBYDIM](https://docs.hotkv.com/commands/cms-initbydim/index.md), [CMS.MERGE](https://docs.hotkv.com/commands/cms-merge/index.md)