A Git commit object just stores the author, date, message, parent commit hashs and the root dir hash.
So, if I want to find out which childs of this commit exist (of course considering only a single repository), how does Git do that? Basically this. But how does Git do that internally? How efficient is that implemented? What is its time complexity? Does it go from every branch head and traverse all possible paths from there and that way, collects all possible childs? Or does it do some clever caching or other method?
I can imagine that the traversing can become really slow if you want to know the childs of a very old commit. It's basically linear to the size of the whole repository. A user which doesn't know about how commits are stored in Git would probably even assume constant time for such request, so a big difference.
I really want to know this, and not something different. It doesn't matter why I want to know this. I just want to know it. That's why I'm not always explaining how I did came up with this question. It really would not add anything to the question.