# PUBSUB NUMPAT

> Return the number of pattern subscriptions on the node.

URL: https://docs.hotkv.com/commands/pubsub-numpat/

```
PUBSUB NUMPAT
```

- Group: Pub/Sub
- Complexity: O(N) where N is the number of subscribed patterns
- HotKV Cloud: all plans
- On-Premise: no license needed

`PUBSUB NUMPAT` returns how many pattern subscriptions, made with
[PSUBSCRIBE](https://docs.hotkv.com/commands/psubscribe/index.md), exist on this node. Each connection's
subscription counts: two connections subscribed to the same pattern count as
two.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Always | Integer | Integer |

## Examples

With one connection subscribed to `news.*` and another to `news.*` and
`alerts.*`:

```
127.0.0.1:6379> PUBSUB NUMPAT
(integer) 3
```

## Compatibility

Redis 7 and Valkey 8 count distinct patterns instead, so in the example above
they would reply `2`. The reply is the same when no pattern is shared between
connections.

## See also

[PSUBSCRIBE](https://docs.hotkv.com/commands/psubscribe/index.md), [PUBSUB](https://docs.hotkv.com/commands/pubsub/index.md),
[PUBSUB NUMSUB](https://docs.hotkv.com/commands/pubsub-numsub/index.md)