Search code examples
couchdbcloudant

Does doc_count include doc_del_count for /db call


When I do a Get /{db} call, CouchDb documentation states the following:

  • doc_count (number) – A count of the documents in the specified database.
  • doc_del_count (number) – Number of deleted documents

Does this mean doc_count excludes deleted document count?


Solution

  • doc_count excludes deleted documents. This is easily verified -- I created a new database via the Cloudant dashboard, created 4 documents and deleted 1. So:

    curl -s 'https://skruger.cloudant.com/blaha/_all_docs'
        {"total_rows":3,"offset":0,"rows":[
           {"id":"3a4a3dc11a24e9aaa7e92688226e24f8","key":"3a4a3dc11a24e9aaa7e92688226e24f8","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
           {"id":"b5f7d2935bc061fc0b5757223a02adf3","key":"b5f7d2935bc061fc0b5757223a02adf3","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
           {"id":"b5f7d2935bc061fc0b5757223a02ec08","key":"b5f7d2935bc061fc0b5757223a02ec08","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}
        ]}
    

    and (output trimmed for brevity):

    curl -s 'https://skruger.cloudant.com/blaha' | jq .
    {
        "db_name": "blaha",
        "doc_del_count": 1,
        "doc_count": 3,
        "disk_size": 202240,
        "data_size": 4499,
    }