Search code examples
xquerymarklogicmarklogic-7nosql

How does MarkLogic's "xdmp:collection-delete" work?


I have a scenario where most of the documents i want to delete are in a collection called "expired". I do not want to overload my servers by running a long running process which would iterate over documents and delete them one by one i would rather do them in batch size using document-delete.

So my question is how does xdmp:collection-delete work ?

Does it iterate over documents and delete them ?

or

Does it do something like DROP Table in SQL and its "instantaneous" ?

I want to know what is the background process for xdmp:collection-delete. I wonder if anyone can draw the flow of how this function handles document for deletion as i want to understand the process in more depth than just overview of what it does.


Solution

  • xdmp:collection-delete() will delete all documents in the collection in a single transaction. While it's not instantaneous, it should be fast, as it just needs to set the deletion timestamp of each document.