I am struggling to delete large number of files loaded in a MarkLogic database. The number of files in a directory that I want to delete is more than 100,000. I usually use two following ways to delete files in query console. Each and every file in the directory is indexed.
for $x in xdmp:directory("/English/","infinity")
return xdmp:document-delete(fn:document-uri($x))
and
xdmp:directory-delete("/English/")
When I execute the any of the above method, I am getting "Time limit exceeded" which breaks the operation.
My question is
If you can clear the forest(s), that is often faster than deleting large numbers of documents.
Otherwise xdmp:directory-delete
is generally the better technique, but for best performance ensure that the following conditions are met:
directory-creation=manual
.If those conditions are met then the bottleneck for deletes is usually locking, so you might consider turning that off temporarily.