guilin 桂林
guilin 桂林

Reputation: 17422

Redis: does separate database improve performance for KEYS and SORT

Does separate database improve performance for KEYS and SORT?

Upvotes: 0

Views: 411

Answers (2)

Andre
Andre

Reputation: 3181

In case you mean that, by spreading the same number of keys across multiple databases, your KEYS and SORT operations will be faster, then the answer is yes.

This is because there are less keys to check against and the time complexity of both these operations is dependent on the number of keys.

At the same time, sorting two result sets in two different databases will be far more costly.

See:

  1. Redis commands - Sort
  2. Redis commands - Keys

Upvotes: 1

Colum
Colum

Reputation: 3914

No. Both of those commands are run on one database. If you have 2 or more databases and wanted to run that command, then you would have to execute in each database, therefor taking twice the amount of time.

Upvotes: 0

Related Questions