White spaces in json docs


#1

Hi,

We are storing JSON docs in couchbase and passing js object to insert and upsert operations. When I view the document from couchbase admin console the white spaces for indentation exist in the document.

insert(key, value, options, callback) 
upsert(key, value, options, callback)

We are using Node.js api, and 4.5.1 Community Edition.

Does couchbase remove whitespaces (caused by indentations) when storing documents? They actually take too much space.

Thanks


#2

Couchbase does not minimize what your app stores directly, but will compress it when storing on disk in server 4.5 and starting in later server releases can compress it between the client and the cluster. All of that said, if viewing it in the console, it may be reformatted anyway.

There are some legacy reasons for that, but if you want to minify it at the app layer before storing the document, you should be able to do so in your Node.JS app.

By the way 4.5.1 is quite old at this point!


#3

We pass js object but not json file to insert/upsert operations. So I think sdk is converting it to json.

So is there a way to remove whitespaces in our NodeJS app?

Actually size of doc with indentation spaces is the actual doc size stored in couchbase I think. I evaluated average doc size of our 10M docs with map/reduce. And when I do sampling and get a document using admin ui, which has indentaion spaces in it, it has a similar size to average size. When I manually remove white spaces, doc size reduces by %30. Actually I have bottleneck on RAM, and I’m trying to minimze footprint of my docs. (By the way we are heavily using view queries so I do not want to impact view which process doc content)

Thanks