Skip to content
Snippets Groups Projects
Commit fb773e21 authored by julian's avatar julian
Browse files

much larger improvement to two_hop query performance

parent c4497536
Branches
No related tags found
No related merge requests found
......@@ -88,23 +88,19 @@ PREPARE two_hop_old (INTEGER) AS
WHERE vertex <> $1;
PREPARE two_hop_new (INTEGER) AS
WITH hop1 AS (
SELECT destination vertex
FROM edge
WITH double_edge AS NOT MATERIALIZED (
SELECT source, destination FROM edge
UNION ALL
SELECT destination, source FROM edge
), hop1 AS NOT MATERIALIZED (
SELECT destination AS vertex
FROM double_edge
WHERE source = $1
union all
select source
from edge
where destination = $1
), hop2 AS (
SELECT source, destination
FROM edge
JOIN hop1 ON source = vertex OR destination = vertex
)
SELECT DISTINCT vertex
FROM (
SELECT source AS vertex FROM hop2
SELECT vertex
FROM hop1
UNION ALL
SELECT destination FROM hop2
)
WHERE vertex <> $1;
SELECT DISTINCT destination
FROM double_edge
JOIN hop1 ON vertex=source
WHERE destination <> $1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment