DBSIZE
DBSIZE
- Group
- Server
- Complexity
- O(1)
- Arity
- 1 (exactly, counting the command name)
- Flags
- read-only, fast
- 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.
Return value
Section titled “Return value”An integer, in RESP2 and RESP3.
Examples
Section titled “Examples”127.0.0.1:6379> DBSIZE(integer) 1520127.0.0.1:6379> SELECT 5OK127.0.0.1:6379[5]> DBSIZE(integer) 0Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.