Question

I want to obtain query's execution time like \timing shows, but it seems there is no effect I send the command by PQexec(), is there any other approach can I obtain a query's execution time ? thanks.

Was it helpful?

Solution

\timing is a client-side command implemented in psql. It reports the time from when psql sends the query to when it receives the response. Take a look at the psql source code for details.

It isn't possible to do that on the server side.

You probably want log_min_duration_statement, client_min_messages, log_duration, explain (analyze on, costs off, timing on), etc if you want server-side timing.

Most likely though, you just want to save the wallclock time before you run the query and compare it to the wallclock time at the end of the query in your client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top