I have a graph with multiple vertices and each of them represent an article from Wikipedia. The edges represent which article the first link of the current article text leads to. The article that is related to every other article is "Philosophy". I have 27 vertices and 26 edges.
If I want to see how far one edge is away from the other, I can query it in two different ways: one is using the size()
function and the other is using the length()
function. But one thing that I noted is that when we use size()
instead of length()
the query runs almost twice as fast. Why does that happen?
demo=# \timing on
Timing is on.
demo=# SELECT * FROM cypher('Wikipedia', $$
MATCH p = (a)-[e:RELATED_TO*]->(b)
WHERE a.name = 'Tulpa' AND b.name = 'Philosophy'
RETURN size(e)
$$) AS (edge_count agtype);
edge_count
------------
18
(1 row)
Time: 4.724 ms
demo=# SELECT * FROM cypher('Wikipedia', $$
MATCH p = (a)-[e:RELATED_TO*]->(b)
WHERE a.name = 'Tulpa' AND b.name = 'Philosophy'
RETURN length(p)
$$) AS (edge_count agtype);
edge_count
------------
18
(1 row)
Time: 7.280 ms