TigerGraph measure GSQL query execution time in milliseconds

285 Views Asked by At

I need to get time taken to execute the GSQL query in TigerGraph, but the problem is the unit is in seconds and since the actual time taken is less than a second it always returns as 0, I need a way to change the unit to milliseconds.

Here is the Query I have

CREATE QUERY time() FOR GRAPH nyGraph { 
    DATETIME before;
    before = now();
    /* my query logic */
    PRINT (datetime_to_epoch(now()) - datetime_to_epoch(before)) as epoch; /* gives 0 */
    PRINT datetime_diff(now(), before) as time; /* gives 0 */
}

Output:

[
  {
    /* Query Results */
  },
  {
    "epoch": 0
  },
  {
    "time": 0
  }
]
2

There are 2 best solutions below

1
On BEST ANSWER

Yes, indeed, the smallest resolution is seconds. You need an external tool like Unix/Linux/macOS time, preferably run on the TigerGraph server to exclude network lag, to get more precise measurements.

Alternatively, you can run the same code from a wrapper/outer GSQL query 10,000 times and measure the time in the wrapper query and divide the duration accordingly.

0
On

If you're checking the logs you can pull out the millisecond time.

Step 1: Run a query

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 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 record you will see the query that you ran along with additional details. One of those details is the query run time.