Timing a Query

There are actually several ways you can time a query, and each has value depending on what you want to measure. You can time a query at
the server (from the time it arrives until the time it completes) by setting the server parameter log_min_duration_statement = 0.
However, that does not measure the network overhead, which can be done using \timing in psql. Then there is the connection and
application overhead that is measured by time at the command-line. This command measures all three aspects of a query:

$ time PGOPTIONS='-c log_min_duration_statement=0 -c client_min_messages=log' psql <<END
\timing
select 1;
END
 
Timing is on.
LOG:  duration: 0.318 ms  statement: select 1;
 ?column?
----------
        1
(1 row)
 
Time: 0.435 ms
 
real    0m0.006s
user    0m0.004s
sys     0m0.004s

Continue Reading »

Timing a Query
By  , Jun 06, 2012

There are actually several ways you can time a query, and each has value depending on what you want to measure. You can time a query at
the server (from the time it arrives until the time it completes) by setting the server parameter log_min_duration_statement = 0.
However, that does not measure the network overhead, which can be done using \timing in psql. Then there is the connection and
application overhead that is measured by time at the command-line. This command measures all three aspects of a query:

$ time PGOPTIONS='-c log_min_duration_statement=0 -c client_min_messages=log' psql <<END
\timing
select 1;
END
 
Timing is on.
LOG:  duration: 0.318 ms  statement: select 1;
 ?column?
----------
        1
(1 row)
 
Time: 0.435 ms
 
real    0m0.006s
user    0m0.004s
sys     0m0.004s

Continue Reading »

Tags:
mailto:?subject= Timing a Query &body= Timing a Query %20:%20http://www.enterprisedb.com/timing-query