0

Having a high ratio of deleted to active documents is generally an anti-pattern in Cloudant and CouchDB (see: https://stackoverflow.com/a/22905621/1033422).

Question: Why is this an anti-pattern?

Community
  • 1
  • 1
Chris Snow
  • 23,813
  • 35
  • 144
  • 309

1 Answers1

1

Every document that is deleted is replaced with small amount of metadata called a tombstone which is used during replication (a tombstone is also created for each document that is in a batch delete operation).

  • Although tombstone documents contain only a small amount of metadata, having lots of tombstone documents will have an impact on the size of used storage.

  • Tombstone documents still show up in _changes so require processing for replication and when building views.

Kim Stebel
  • 41,826
  • 12
  • 125
  • 142
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
  • So, why this is an anti-pattern?(: Or may be this isn't an anti-pattern at all, just a one of possible state of a database? – Kxepal Nov 07 '14 at 10:17
  • For me the anti-pattern is that many new users coming to CouchDB aren't aware of the consequences of deleting documents and expect DELETE to work the same as in a RDBMS, but in CouchDB relying on heavy DELETEs can lead to performance problems. – Chris Snow Nov 07 '14 at 10:30
  • It is possible to reclaim space through PURGE and then compacting, though it is not recommended because it rebuilds all views on the database. If you have to delete a lot, you'd better just create a new database. – Mariusz Nov 09 '14 at 11:08