Inserting new documents vs. ArrayAppend when updating is not required

My requirement is to insert documents into a bucket. These are simple documents with no more than 10 attributes. These documents will never need to be updated, but could be deleted. These documents need to be queried based on about four attributes.

Is there any benefit in using a single document and performing an ArrayAppend to an array of documents? As opposed of using many documents, that is.

It all depends on how many documents you are taking. How often you add new document/delete. How is search condition.

If Single document. ==>

  • You can use USE KEYS “document key” and get whole document , no index needed
  • number of elements are more document can be bigger.
  • As you know document key you can directly process with SDKs no N1QL is needed
  • To INSERT into ARRAY/DELETE you can use SDK
  • process search condition in SDK
  • If use N1QL we need to get the whole document

If multiple documents

  • You must use Index and N1QL
  • Document is small
  • Expandable as number of document grows.
1 Like