1

The query

 CALL db.labels() YIELD label 

in Neo4j provides the labels present inside the graph

The same query, on memgraph, gives an error

`input 'CALL' expecting {CREATE, DELETE, DETACH, DROP, EXPLAIN,   
    MATCH, MERGE, OPTIONAL, REMOVE, RETURN, SET, UNWIND, WITH}`

1 Answer 1

1

It is possible to rewrite the query in the following way

MATCH (n) UNWIND labels(n) AS labels RETURN DISTINCT labels;

to get equivalent results.

Results returned from both queries are equal, but the alternative query is slower because it scans the entire dataset. In the implementation of the query in question, the result could be cached. The execution time of the alternative query depends on the number of nodes and the number of labels. In most cases, the number of labels within the dataset is significantly smaller than the number of nodes, which means that the query returns in linear time. Even in the case where the number of labels is higher than the number of nodes database system should respond in a reasonable time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.