on-internet
← Community

Python and Redis. Why is scan_iter() so much slower than keys() with mget()?

Stack Overflow ·

I made a script to compare query speeds between methods in the redis library. As I understand it, I should not use redis.keys() because it's a blocking function. The preferred method is scan_iter(), which doesn't block. That makes sense. But I don't understand why scan_iter is so terribly slow. This script uses three techniques to query a redis database. Use redis.keys() to get all of the keys. Use redis.mget() to get all the values. Use a for loop with redis.scan_iter and redis.get() to get the values. (Note I don't need keys, just values) Use redis.scan_iter() to get all of the keys. Use red

Comments

Sign in or sign up to comment and upvote.

No comments yet.