# DBSIZE

> Return the number of keys in the selected database.

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

```
DBSIZE
```

- Group: Server
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`DBSIZE` returns how many keys the connection's selected database holds.
For every database at once, read the `keyspace` section of
[INFO](https://docs.hotkv.com/commands/info/index.md).

## Return value

An integer, in RESP2 and RESP3.

## Examples

```
127.0.0.1:6379> DBSIZE
(integer) 1520
127.0.0.1:6379> SELECT 5
OK
127.0.0.1:6379[5]> DBSIZE
(integer) 0
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[SELECT](https://docs.hotkv.com/commands/select/index.md), [INFO](https://docs.hotkv.com/commands/info/index.md), [SCAN](https://docs.hotkv.com/commands/scan/index.md),
[FLUSHDB](https://docs.hotkv.com/commands/flushdb/index.md)