How to take the time in milliseconds of a query?

So i want to take the time of a query in milliseconds and print it on my run:
CREATE QUERY select1_bun() FOR GRAPH etapa4 {

DATETIME before;
Start = {Twitch_Streamer.*};
SumAccum @@vertexCNT;

before = now();
Result = SELECT s FROM Start:s WHERE s.life_time > 290 and to_datetime(s.created_at) == to_datetime(“2016-02-16”) ACCUM @@vertexCNT += 1;
PRINT datetime_diff(now(), before) as time;

//PRINT Result;
PRINT @@vertexCNT;

But all i get is 0 probably because is so small and what i return is in seconds…any idea how to convert it in milliseconds?

@iancujianu98 Do you have access to logs? It does show time in ms in the logs. As for gsql you could take the epoch time - epoch time to get the difference.

No, i don’t access the logs, mainly because i dont know how
But i ll try the approach using epoch

I’m trying to use the epoch too, but there is no function reference to get the epoch with microseconds.

The datetime_to_epoch function returns an int, without the microseconds.

Is there some (undocumented) function to retrieve the actual epoch in microseconds?

@phuysmans @iancujianu98

Each time a query is ran there will be the query performance is logged. The easiest way to find this information is shown below. Enterprise users will generally have log monitoring setup and will pull this statistic into a dashboard.

Step1 Run a query

Here you will see I ran a query called edgeCrawl. Next I’ll copy that query name to search in the Admin Portal. (Click on the top right ADMIN button)

Step 2 Search logs

On the left side you can see I navigated to Monitor then clicked on Logs. After this paste in your query to the Pattern search box. To find results easier toggle off all and select RESTPP

Step 3 Explore Logs

If you look at the second record you will see the query that we ran along with additional details. One of those details is the query run time.

Zoom In on Query Run Time (in MilliSeconds)

You can see for edgeCrawl the run time was 39ms

Thanks for the pointers. I will extract the query time from there combined with explicit log statements.

1 Like


Extra Tip: If you want to setup a monitoring stack to monitor all your query performance you can do that as well. TigerGraph supports the ELK Stack monitoring solution.

Set up Log Viewing with Elasticsearch, Kibana and Filebeat :: Docs