Size of the document in couchbase

Hi,

In one of the posts Finding the size of the documents that are stored inside Couchbase server it is mentioned that we can use couch_dbdump to find real and compressed size of the document. Could anyone help here as how to use this?

And also in couchbase if we view document using cocuhbase console, the json has some spaces, so should we need to consider those spaces in calculating document size?

lets say you are storing document foo with cbc tool in the default bucket:

$ cbc create -Ucouchbase://localhost/default -V'{"num":42}' foo
foo                 Stored. CAS=0x148bc02895350000

Now lets determine vbucket (partition) this key falls into:

$ cbc hash foo
foo: [vBucket=115, Index=0] Server: localhost:11210, CouchAPI: http://localhost:8092/default
Replica #0: Index=-1, Host=N/A

This information is enough to use couch_dbdump:

$ sudo /opt/couchbase/bin/couch_dbdump  /opt/couchbase/var/lib/couchbase/data/default/115.couch.1
Dumping "/opt/couchbase/var/lib/couchbase/data/default/115.couch.1":
Doc seq: 2
     id: foo
     rev: 2
     content_meta: 128
     size (on disk): 20
     cas: 1480488183055843328, expiry: 0, flags: 0, datatype: 1
     size: 10
     data: (snappy) {"num":42}

Total docs: 1