erikdubbelboer / phpRedisAdmin

Simple web interface to manage Redis databases.
http://dubbelboer.com/phpRedisAdmin/
3.11k stars 666 forks source link

Limit the max number of keys when scanning #206

Closed LeoHsiao1 closed 3 months ago

LeoHsiao1 commented 3 months ago

Hi, glad to see you're still maintaining this 12 year old project! Among the redis web GUI tools, phpRedisAdmin is still the most powerful one.

But now there is a serious problem: if the redis db contains more than 100,000 keys, it takes phpRedisAdmin tens of seconds to open the db, or even timeout. I have a simple solution: limit the max number of keys when scanning.

For reference, AnotherRedisDesktopManager also has this limitation, and the max number is 500. https://github.com/qishibo/AnotherRedisDesktopManager/blob/d373d653063c2a0c256c743777118b92231010ba/src/components/contents/KeyContentStream.vue#L199

LeoHsiao1 commented 3 months ago

Sure. I added a line of comment.

LeoHsiao1 commented 3 months ago

I have tested this and found that even if the redis db contains millions of keys, a query with export SCAN_MAX=1000 takes less than 1 second. A query with export SCAN_MAX=5000 takes nearly 5 seconds.

erikdubbelboer commented 3 months ago

Thanks!

GregOriol commented 2 weeks ago

Wait, does this mean that the display will be incomplete, and that there is no mention about it anywhere to the user?

There is also no way to "load more"?

I agree with a need to limit issues when servers have a huge number of keys, but this solution is really problematic.

LeoHsiao1 commented 2 weeks ago

In AnotherRedisDesktopManager, if the number of keys exceeds 500, it displays the "load more" button. It would be nice to implement this feature in phpRedisAdmin, but it would require more code changes.

An alternative is to display a warning at the bottom of sidebar: "reached the limit" I can try to add the warning.

LeoHsiao1 commented 2 weeks ago

I came up with another solution that always shows the number of keys being scanned and the limit. It is displayed like this: screenshot-20240919-175419

GregOriol commented 2 weeks ago

Kind of better, but not sure it would be clear enough for users. I think some "keys limit reached" message should be clear, or a "more" button would make it more clear.

LeoHsiao1 commented 1 week ago

Adding "load more" button is definitely better, but this project currently lacks contributors. I've opened a new PR to make a small patch.