Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

DBSIZE

Last updated
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.

An integer, in RESP2 and RESP3.

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

Same as Redis 7 and Valkey 8.

SELECT, INFO, SCAN, FLUSHDB