Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any limit on the number of arguments that redis commands such as ZADD or HMGET can handle?

Tags:

redis

I'd like to use single ZADD or HMGET commands instead of a MULTI/EXEC.

Is there any limit on the number of (score, member) tuples that ZADD can handle?

Is there any limit on the number of fields that HMGET can handle?

like image 716
Adriano Di Giovanni Avatar asked Mar 20 '17 18:03

Adriano Di Giovanni


People also ask

What is ZADD in Redis?

Redis ZADD command is used to add all the specified members with the specified scores to the sorted set stored at key. If a specified member is an existing member of the stored set, the score is updated and the element reinserted at the right position to ensure the correct ordering.

Are Redis commands case sensitive?

We show the redis commands used in uppercase notation, this is in line with the documentation. Note, however, that Redis itself is case-insensitive here so set is equivalent to SET. computing with data.

Which command is used to obtain all the keys in a database?

The Redis KEYS command returns all the keys in the database that match a pattern (or all the keys in the key space). Similar commands for fetching all the fields stored in a hash is HGETALL and for all fetching the members of a SMEMBERS. The keys in Redis themselves are stored in a dictionary (aka a hash table).

How do I see what is stored in Redis?

A Redis server has 16 databases by default. You can check the actual number by running redis-cli config get databases. In interactive mode, the database number is displayed in the prompt within square braces. For example, 127.0. 0.1:6379[13] shows that the 13th database is in use.


1 Answers

The theoretical limit is pretty high, but you should design your reads in such a way that you don't reach it. The main reason for keeping reads sanely-sized is to avoid blocking the server for too long.

Several hundreds or thousands should be a good ballpark, but the best thing would be to test it yourself with your code and data.

The hard limits, such as they are, are:

  • A hardcoded 1GB for client query buffer (PROTO_MAX_QUERYBUF_LEN in server.h)
  • The maximum number of arguments is the maximal value of the int C data type, which is usually signed and 4 bytes long meaning up to 2,147,483,647.
like image 145
Itamar Haber Avatar answered Oct 01 '22 19:10

Itamar Haber