pythonredis

redis (ledis) become slow after flushdb


I use the following command to clear the Ledis index.

from redis import StrictRedis
db_value = 7
redis = StrictRedis(host=HOST, **cloud_cfg, db=db_value)
redis.flushdb()

After I clear the index, I use following command:

from redis import StrictRedis
db_value = 7
redis = StrictRedis(host=HOST, **cloud_cfg, db=db_value)
res = redis.mget(['1', '2', '3', '4', '5', '6', '7', '8', '9']) 

It takes 4 second.

But when I use mget in DB 8.

It only need 0.193 second.

My questions are:

1. Why my DB become slow after flushdb?
2. How can I fix it?

more information:

redis version(python): 4.5.4

ledis version(server): 1.3.8


Solution

  • I found that after using mset to reset a large amount of data, the mget speed returned to normal. I still don't know why, but people encountering similar issues might want to give it a try.