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}`
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Roberto Franchini
  • 1,016
  • 7
  • 13

1 Answers1

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.

buda
  • 460
  • 4
  • 8