Remove a node and its children

Hi,

I’m currently using dgraph and I was checking that I cannot really remove a node, instead of that I have to remove its edges and triples but I was thinking in one use of case. What happens if I have a tree (Think about a files system which actually is a tree) and I have something like
/home/user/Downloads/myDownload/[myFirstDownload mySecondDownload etc…]

The [ ] representation is thinking that myFirstDownload and so on… are children of Download.

Then I want to remove Download so in dgraph I just only remove the edge that connects user with Download something like:

mutation {
delete {

 <user uid> <child_edge> <download uid> .

}
}

and then the relation will be deleted. So my question is… If I remove that relation will download (and consequently children) be removed?

I meant you do you have a kind of garbage collector condition to make a node available again? Because the Download node and its children won’t be used again and I expect that all of these uids make it available after that.

Thinking this example with zillions of nodes subsequiently of that download node

The disconnected children should still remain in the database. They are still accessible via their uid and their relations among them. You would just not be able to traverse to them via your ‘children’ relations.

So if I want to make memory available from the disconnected part I have to remove all their relations each other? I want to free memory to avoid overhead in database

Hey @gustavmb

@matthiasg is very right here.

There isn’t any overhead in terms of query lookups/latencies. Yes, you may have some stuff written down to disk which you won’t be accessing anymore, so if you are concerned about that you can delete the disconnected part manually.

Update - The disconnected part would also be available through functions like eq, ge etc. So you might want to delete it manually.

Ideally, before deleting the parent directory, you’d want to find all it’s children, and then make those part of the delete operation as well. That’s the best way to do this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.