Three WHERE slow query down
One thing that sometimes works is to rewrite a series of OR conditions into a sequence of UNIONs:

CREATE TABLE restriction
AS
SELECT '100' as to_cost, a.nextedge as target_id, a.currentedge as via_path
FROM adjacency a 
 JOIN adjacency b ON a.nextedge = b.currentedge
WHERE a.sourcenode = b.sourcenode AND (a.degrees &lt; 45.0 OR a.degrees &gt; 315.0)
UNION 
SELECT '100' as to_cost, a.nextedge as target_id, a.currentedge as via_path
FROM adjacency a 
 JOIN adjacency b ON a.nextedge=b.currentedge
WHERE a.targetnode = b.targetnode AND (a.degrees &lt; 45.0 OR a.degrees &gt; 315.0)
UNION 
SELECT '100' as to_cost, a.nextedge as target_id, a.currentedge as via_path
FROM adjacency a 
 JOIN adjacency b ON a.nextedge=b.currentedge
WHERE a.targetnode = b.sourcenode AND (a.degrees BETWEEN 46.0 AND 224.0)
;


You don't need an additional distinct here, as UNION will take care of that. I also replace the ancient, outdated implicit join syntax with an explicit JOIN operator.

You can additionally try indexes on:


adjacency (nextedge, sourcenode)
adjacency (currentedge, sourcenode)
adjacency (nextedge, targetnode)
adjacency (currentedge, targetnode)