Fetching all nodes of a directed graph by an id of any node
I am not well qualified to answer this, as I know nothing of PostgreSQL or the RECURSIVE extension you are using, so unfortunately I cannot very well comment on your solution.

However perhaps it can be tackled with (relatively!) standard SQL. Let's define a temporary table 

CREATE TABLE #Temp ( id int, status int )


A status of 1 will indicate the node is reachable, but it has not yet been processed, a status of 2 indicates the node is reachable, and all immediate descendants have been added. We initialise by inserting the starting node ( I think in your example it is 2858 ).

INSERT INTO #temp ( id, status ) VALUES ( 2858, 1 )


Now we can set up a loop to insert all the reachable nodes:

DECLARE @x int 
WHILE 1 = 1
BEGIN
  SELECT @x = -1 -- Some value that is not a valid node id
  SELECT @x = id FROM #Temp WHERE Status = 1
  IF @x = -1 BREAK -- All reachable nodes processed.

  INSERT INTO #temp( id, status ) 
  SELECT descendant_id, 1 
  FROM DocumentDependency WHERE predecessor_id = @x
  AND descendant_id NOT in ( SELECT id FROM #Temp )

  UPDATE #temp SET status = 2 WHERE id = @x
END


When the loop terminates, #Temp should contain all the reachable node ids. Provided suitable indexes are defined, I think this should be reasonably efficient. As a variation, you could perhaps process multiple nodes with status 1 on each iteration of the loop, I will leave that as an exercise ( you may need an extra status value to differentiate between nodes that have just been added and nodes that are being processed ).