Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Execution time of each query

In column y I want to return query serial number. I know that it’s not right, but I have no idea how can I do this.

WITH '
MATCH (a:authors{name:"Lui Lis"})-[:`WROTE`]->(b:papers)-[:`REFERS_TO`]->(c:fieldsofstudy)
RETURN c.name AS field_of_study, count(b) AS number_of_papers
' AS query
UNWIND RANGE(0, 4) AS i
WITH i, query, datetime.realtime().epochMillis AS start
CALL apoc.cypher.doIt(query, NULL) YIELD value
WITH i, MAX(datetime.realtime().epochMillis-start) AS execTime
WITH collect(execTime) AS per_query_time, AVG(execTime) AS avg_time
UNWIND per_query_time AS x
RETURN x, RANGE(0, 4) AS y, avg_time

Can you please help me

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It’s not clear what you mean by a "serial number".

If you want y to be the same as i, this query should work:

WITH '
  MATCH (a:authors{name:"Lui Lis"})-[:`WROTE`]->(b:papers)-[:`REFERS_TO`]->(c:fieldsofstudy)
  RETURN c.name AS field_of_study, count(b) AS number_of_papers
' AS query
UNWIND RANGE(0, 4) AS i
WITH i, query, datetime.realtime().epochMillis AS start
CALL apoc.cypher.doIt(query, NULL) YIELD value
WITH i, MAX(datetime.realtime().epochMillis-start) AS execTime
WITH COLLECT({x: execTime, y: i}) AS per_query_times, AVG(execTime) AS avg_time
UNWIND per_query_times AS z
RETURN z.x AS x, z.y AS y, avg_time

If you want y to be the index of each query time (across all i values), replace the last 3 lines of the above query with:

...
WITH COLLECT(execTime) AS per_query_times, AVG(execTime) AS avg_time
UNWIND RANGE(0, SIZE(per_query_times)-1) AS y
RETURN per_query_times[y] AS x, y, avg_time
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading