fastogt / fastoredis

FastoRedis is a crossplatform Redis GUI management tool.
https://fastoredis.com
GNU General Public License v3.0
314 stars 28 forks source link

Don't use `KEYS *`, switch to `SCAN *` if possible #49

Closed badboy closed 9 years ago

badboy commented 9 years ago

I just wanted to try fastoredis, but it already fails with a small instance (~20Mb of data). The main window is completely unresponsive.

This is probably largely due to the use of KEYS * (https://github.com/fasto/fastoredis//blob/master/src/core/redis/redis_driver.cpp#L39), which is one of the most expensive commands in Redis. It's blocking and always needs to scan the whole database. An alternative is to use the SCAN command, that will iteratively scan the whole database without blocking for too long (the downside being that you might miss keys if they are added in between).

For now I advise atleast having a small warning that this should best not be used against large production instances. In the longer run replacing KEYS * is definitely the desired solution.

topilski commented 9 years ago

Hello @badboy, thank you for issue, i didn't test FastoRedis on big database, so how can i understand i must execute 'scan' command in a loop while server not return 0. And the main question is how present this functionaliti to users, now it is simply 'load content' in context menu. @badboy, how do you think we can make more options where user may choose how much keys he wants and what patterns for selection to use?

topilski commented 9 years ago

@badboy in 0.7.0 version you can try new behavior, wait your opinion.

badboy commented 9 years ago

Seems to work much better now.