couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Purge_Documents" by AndreyNiakhaichyk
Date Fri, 02 Mar 2012 14:53:55 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Purge_Documents" page has been changed by AndreyNiakhaichyk:
http://wiki.apache.org/couchdb/Purge_Documents

New page:
When you [[HTTP_Document_API#DELETE|delete a document]] the database will create new revision
of it which contains _id, _rev, _deleted fields. The reason of it to ensure that deletion
of document will be replicated to other databases (if you are using replication). If after
deletion you will [[Compaction#Database_Compaction|compact a database]], you will find that
the reference to the deleted document still exists. If you call [[HTTP_database_API#Changes|_changes]]
you will make sure about it. It will be only one revision available which we call '''deleted
mark revision'''. Again it is necessary for the replication integrity as it was mentioned
before.

The '''_purge''' operation removes the reference to the deleted document from the database.
To perform a purge operation you must send a request including the JSON of the document IDs
that you want to purge and revisions for purging. For example:
{{{
POST /mydb/_purge
Content-Type: application/json

{
  "c7a59f0d08d28928a62124fa16000ea7" : [
    "2-02be3a9b23b4402160ad678e208afb8e"
    ]
}
}}}

The response will contain the purge sequence number, and a list of the document IDs and revisions
successfully purged.

{{{
{
   "purged" : {
      "c7a59f0d08d28928a62124fa16000ea7" : [
         "2-02be3a9b23b4402160ad678e208afb8e"
      ]
   },
   "purge_seq" : 1
}
}}}

Notes:
 * '''The purging is not replicated to other databases.''' Keeping deleted mark revision is
only way to guarantee the replication integrity. If you use purging you may break this. There
is only way to avoid this is check that revision of deleted documents is the same in all replication
targets and sources.
 * There is no way to purge automatically all deleted documents. You have to send a _purge
request with all documents IDs and revisions.
 * Purging documents does not remove the space used by them on disk. To fix this run a database
[[Compaction#Database_Compaction|compact]] and also compact views.
 * There is no any reason to purge old revisions of existent documents. You can configure
[[HTTP_database_API#Accessing_Database-specific_options|_revs_limit]] to do it automatically.

'''Warning!!!''' All notes above is trying to inform you that _purge should be used only in
extraordinary cases, for example you need to delete secure information after some mistake.
If you still need use _purge it may mean that you probably need to move some data into another
NoSQL or SQL databases.

Mime
View raw message