Can anyone tell about key(each record has an indexed key that is unique in the set) lenght and other “key” limits? What type of key is better to use?
Not sure if I understand your question right.
Aerospike automatically transforms your key into a 160-bit hash, so you can use a string of any length as your primary key. I tend to use something like “CartItem_12345” where 12345 is an ID. It doesn’t matter what you use as your key, it will always take the same amount of memory/space in the index for the record itself. However, you might need to store the string in case you use it as a foreign key / have relations. E.g. it makes a difference if you need to store a “User_12345” or a “User_someultralongemail@somedomain.tld” in a bin called “customer” for your cart records.
Designing the primary key to allow fast access is crucial to minimize amount of GET’s // latency in your application. So if for example your users must have a unique email, you can use "User_mail@example.org" as your primary key and can always look up the right user for your login form logic.
Before you decide on what to use as your primary key, you should think about the main usage later on (how you want to be able to query the data). This is the opposite of a SQL-schemadesign process where you first think about the structure and then on how to query. T
Thank your for the answer.
Yes, I know that Aerospike automatically transforms key into a 160-bit hash.
I need to store in DB key. Also I need keys when do scan and query. It is possible to specify WritePolice with sendKey = true then Aerospike will store keys (WritePolicy sendKey effect).
I want to know if there are any limits of key length when I set sendKey = true for write policy?
There is no limit to the key size, but if you store it, you consume storage space. So it effectively adds to the size of the record
Nice, thank you for the answer. Yes, I understand that it will consume space. I need key because during scan, search I need info about key (it is requries by app logic).
Years after the question, I needed to add that keys can be string, integer or bytes (blob) and the following explains size limits
This topic was automatically closed 84 days after the last reply. New replies are no longer allowed.