When to use SQL vs Key Value Operations

Key-value operations are much faster than query operations. If you asked me for a number, I would say 20 times faster.

I am not seeing a way to search for documents and return a list of keys. I don’t see a way to iterate over all the documents in a collect.

Here is one way to get document keys - How to quickly list 1M document identifiers?

Here is another - python - how to get all the key from one bucket in couchbase? - Stack Overflow ( using map/reduce ).

Detailed instructions for using map/reduce :
Here’s the easy/quick way to get the ids.

  1. go to the couchbase webconsole
  2. select “Views”
  3. Click on “Add View”
  4. Complete Design Document Name with “allids” (giving design/dev)
  5. Enter View Name as “getids”
  6. Click on Save
  7. Click on Publish for the View.
  8. curl -u Administrator:password ‘http://localhost:8092/my_bucket/_design/allids/_view/getids?reduce=false’ > allids

The default Map without any Reduce gives all the ids in the bucket.

{"id":"999993","key":"999993","value":null}, {"id":"999994","key":"999994","value":null}, {"id":"999995","key":"999995","value":null}, {"id":"999996","key":"999996","value":null}, {"id":"999997","key":"999997","value":null}, {"id":"999998","key":"999998","value":null},

There is an upcoming feature - range-scan - that will also provide document keys.