Bulk Deleting 100.000 children in a folder, under ...
# help-with-umbraco
s
I am absolutely stumped. Something has gone awry in this setup, that has caused it to amass 1316 pages of 100 images each, accumulated over 4 years of a hangfire job continously stuffing it every day. When I try to delete the folder itself, the program hangs for hours without anything happening, and I get a timeout error from the database if I try to delete 100 at a time. I changed the list view to showcase 10000 at a time, can't delete them then If I try to move the images it instacompletes, saying done, without moving any
If I know the id of the folder, can I somehow sever it, and delete it outside of the backoffice?
Would it work, to just set all umbracoNode's that have the folder as a parent, to trashed?
j
Last time I needed to do this I used the MediaService to programmatically delete in batches, with periodic emptying of the recycle bin.
s
I tried to do that, but at the rate it was going, it's going to take 51 hours due to not knowing how to circumvent the write lock error (-334)
Which occurs when I try to do async deletion
So I ended up just going straight into the DB to delete them; I would love any feedback on my approach to make sure I did not cause any side effects. I changed the parentNode of all elements in my folder, to -21, and set their trashed value to 1 Then I deleted them from umbracoNode, after having deleted the constraint values in the following tables; umbracoContent umbracoContentVersion umbracoMediaVersion umbracoPropertyData Based on id (I did not ever remove and re-apply constraints)
And it worked. The query took 30 seconds, as opposed to 51 hours of deleting one by one programmatically
j
51 hours, OUCH. TBH, I'm not sure about the database approach as it's not recommended to go messing around with the DB. Foreign key constraints should be enough, but there may be some references without constraints so be sure to give it a thorough test. Be sure to clear nucache, examine indexes etc. You'll also need to manually remove the media files themselves.
s
Appreciate the shout about clearing stuff. I am still struggling to understand the relations between files and nodes
14 Views