Skip to main content

Description

Returns the number of keys in the currently selected database.

Method Signature

Parameters

This command takes no parameters.

Return Value

result
number
The number of keys in the database

Examples

Get database size

Monitor database growth

Check if database is empty

Track deletes

Performance

DBSIZE is an O(1) operation - it returns the count instantly without scanning the keyspace.

See Also

  • keys - Find all keys matching a pattern
  • scan - Incrementally iterate over keys
  • flushdb - Delete all keys in the database