'doc_del_count' bigger than 'doc_count' on CouchDB

烈酒焚心 提交于 2019-12-10 22:10:49

问题


I have just received an Android project that works with CouchDB and CouchBase Lite.

The first step in the app is a replication, more or less the replication spent more than 2 hours, but usually it never finish.

On the dataBase site I can see that doc_del_count is bigger than doc_count, It does not make sense because we never delete documents.

In this case the replication process handles 519695 documents and 498264 of them are deleted, so it is crazy

My questions are:
Why replication download doc_del_count if they are deleted documents?
How Can I see those deleted documents?
Can I removed all those doc_del_count? How?


回答1:


Why replication download doc_del_count if they are deleted documents?

Because deleted documents are never truly deleted in CouchDB. Instead, the _deleted field is set to true. This is primarily to allow proper synchronization where updates can happen in more than one place. Imagine that a document is deleted from one place, but updated to include new information in another. Which operation should take priority? CouchDB has no way of knowing, so it keeps both versions around, and lets the application designer handle conflict resolution as they see fit.

How Can I see those deleted documents?

Consult this answer for details, but the short answer is: include revs_info=true in your query per the documentation.

Can I removed all those doc_del_count? How?

You can compact the database, but this won't remove deleted documents, for reasons explained above.



来源:https://stackoverflow.com/questions/45127024/doc-del-count-bigger-than-doc-count-on-couchdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!