How to get average size of document_id in couchbase


I would like to know, how to get average size of document IDs in couchbase. Is there any REST API for that?

Thanks in advance.

With Couchbase 4.x, you can use the following N1QL query.

FROM my_bucket;

Hi @geraldss Thanks for reply. Is there any REST API to get the same like /pools/default/buckets/stats.

There is a N1QL REST API, but it is not yet in the documentation:

You can send the REST request to port 8093 on any node running the Query service. You need to pass a statement parameter containing your N1QL statement.

@geraldss Thanks for sharing link. Its really helpful. :slight_smile:

1 Like

@ch.harish1271 why don’t you just execute this statement through the SDK of your favourite language? That’s the recommended way to access it :slight_smile:

@daschl We have some scripts wich developed by using REST API. So to add more features in that , we prefer to use API instead of SDK.

@geraldss @daschl We are using couchbase 3.x version. In that N1QL is not supported. How can I get the Key size details?

You should upgrade to 4.x.

@geraldss We will upgrade to 4.x soon. Is there any possible way to find out average size in 3.x?

You can use a MapReduce view to calculate the total length of all the keys. After that, you can divide by the number of entries in your bucket.

@geraldss Thanks for reply. I am new to map reduce in couchbase. Can you please share any good references to get this.

Hi @ch.harish1271, I don’t have any pointers besides the product documentation.

If you will be upgrading soon, you should decide whether to learn the MapReduce views or wait for your upgrade.