Key/Value Pair with .net SDK


Both Couchbase classes I’ve been to have emphasized the speed of Key/Value pairs over documents. I’ve been trying to figure out how to store and retrieve Key/Value pairs with the .net sdk. This is what i’m currently doing:

 var upsert = bucket.Upsert(id, value);

Where value is a string.

When I view this data in the CB console I see the key and a hash of the value I inserted. However, I have some diagnostics in place and I don’t see a difference between this and using a document. I’m seeing about 7-8 ms to retrieve both from CB using:


I was lead to believe that the key/value retrieve would be < 1ms.

Am I missing something?



Are you sure it wasn’t rather emphasizing speed of Key/Value retrieval over View retrieval?

A Document is little more than a Key/Value pair with special semantics for the value: eg. if it is a JSON document it will be searchable with N1QL and views.

Couchbase stores everything in the same manner: a Key, a Value (raw string, binary data, JSON, …) and Metadata (key is sometimes considered part of the metadata).

The three of which fall under the umbrella of the concept of a Document. The only spot where there could be performance differences is if you store raw content vs. JSON if you unmarshall the JSON into domain objects (because there is an additional overhead there).

On the other hand, the method of retrieval has a clear impact on performance: knowing the Key and going straight for the corresponding document using the K/V api vs. querying a View (by a secondary criteria, like the value of a field in your JSON, since views are secondary indexes) and then fetching the associated document(s).


Thanks for the response. I went back to the training deck and you are correct. It says Key/Value Document vs. Index. I’m so glad cause I thought I was loosing my mind. Should the retrieval of the document by key in the sdk be sub 1ms? I’m getting a range of 8-10 ms.

Thanks again!


The 8ms range is not too far off. The server should be able to serve the data in the sub-millisecond to 1ms range, but you have to account for network transfer time and latency when you measure on the client side.


I have found that Views are very slow due to scatter gather, but this question seems to look for a difference between getting a value via: Get vs. Upsert.


Nope. It was just a misunderstanding of verbiage on my part.