Questions regarding primary index

I’ve read that I need a primary index to query by meta().id so I have 2 questions regarding this index

  1. In relational databases, a primary index is used to fetch data that is not part of the secondary index
    let’s say I’m running a query by a specific field and I have a matching secondary index, but in the select I would like to get the entire document, when will happen?
    Will it use the secondary index and it will need the primary to fill the rest of the fields?

  2. If I have a lot of queries with joins according to the id of the document, should I create few primary indexes (on each of the nodes) to make it run faster?


Couchbase is Distributed key value store. N1QL requires index (primary or secondary) to the keys so that it can fetch the documents. Primary index will have all the indexes on the bucket.

The following blogs give you idea.

Primary index is not recommended in production.