Performance considerations for Querying and Accessing Documents

Wanted to understand a bit of internals around how querying and accessing documents works for couchlite

If I put all the information I need in the view as key/values, would it help in saving performance? What additional overhead there is to access the documents returned from the query?

thanks
M

Yes, it’s most efficient to emit the data you need into the value during the map function, because getting the value from the QueryRow doesn’t cause an extra database lookup.

QueryRow.document is implemented as db.getDocument(row.documentID). That is, each query row stores the ID of the document that emitted it, but loading the document may take another database lookup.

Two exceptions to this:

  • Don’t store more in the value than you need. The bigger the value the more overhead there is to reading the query row.
  • The database does cache recently-used documents in memory, so if the row’s document is already cached, getting the document is extremely cheap.
1 Like