Search code examples
databasehashnosqlcouchdbb-tree

CouchDB: Good document ids to lower storage requirements


So I did some research and apparently the storage requirements can increase significantly with key size.

In reality I want to be able to use a "long int" as my key but this won't be possible as couchdb requires that keys are strings correct ? Is there any way to circumvent this ?

Because my ids look like:

{ "_id" : "10209939", ....data here ... }
{ "_id" : "10209940", ....data here ... }
{ "_id" : "10209941", ....data here ... }

I would like to keep them numerical to do range queries. But since the storage increases along with key length, my storage will explode. In a sense, these ids represented as strings take many more bytes that they would should they be interpreted as long ints.

Has anybody had experience storing documents with a "numerical" integer as ids ? How did you get good storage efficiency given that couchdb understands "_id" as being a string ? Can we tell it, no it's a "long int" not a string.


Solution

  • The id must be a string. No alternative.

    You can do range queries, but only a lexical range - not a numeric range.