"why is the couchdb documentation suggesting docs should not be emitted in the view?" Code Answer

3

when you emit the entire document in a view, you are effectively duplicating the document on disk. this is because each view has it's own file that includes the results of running the view on the database. thus, if you have 3 views where you output your document, you have 4 copies floating around. (not counting multiple revisions of documents, which of course adds more duplicates)

couchdb uses disk-space very liberally in order to make writes occur faster, largely due to their choice to use an append-only structure. as a result, using views to output the same document repeatedly can cause your disk-usage to grow very quickly. (compacting your database and views generally helps, but it should not be something you want to force yourself into constantly)

the trade-off to leaving the documents out is that when you are reading from the view, couchdb will need to internally find the document and include it in the view's output. since it is looking things up based on the id, it's a very fast operation, but it still incurs overhead. thus, while this pattern is generally best-practice, you should be open to examining the trade-off in the context of your application.

By timsabat on January 12 2022

Answers related to “why is the couchdb documentation suggesting docs should not be emitted in the view?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.