Best way to time a query

I want to time some gsql queries and I’ve been doing it with the *nix time command, e.g.

time gsql -g mag “USE GRAPH mag SET query_timeout=240000 RUN QUERY find_papers(12345)”

However, for simple queries that on the gsql console come back immediately, this still gives times on the order of half a second.

What is the best way to time a query? I see TIME, LOCALTIME, and LOCAL_TIMESTAMP in the reserved words list, so I assume these are built-in functions, but I am not sure how to use them. Can you given an example?

P. S. I get similar run times when I omit “USE GRAPH…” and “SET query_timeout…” and just time the “RUN QUERY…”

Will “time curl http://localhost:9000/query/mag/find_papers?param=12345” work for you? Replace with the one in the query definition.

-Chengbiao

yes that works well. Thanks!

Follow up question: When you use the REST endpoint, is there a way to set the query timeout threshold just for that query? Alternatively, how you you set query_timeout permanently on the server? Doing “SET query_timeout=…” in the console only seems to affect the current gsql session.

It’s doable via providing a header GSQL-TIMEOUT for the rest call, e.g., curl -H “GSQL-TIMEOUT: ” “”

Thanks,

Chengbiao