how to get current sql execution time?

Started by sunpengover 15 years ago6 messagesgeneral
Jump to latest
#1sunpeng
bluevaley@gmail.com

when I use the psql to send a sql, how to get current sql execution time?

#2Rob Sargent
robjsargent@gmail.com
In reply to: sunpeng (#1)
Re: how to get current sql execution time?

\timing

Show quoted text

On 10/14/2010 04:47 PM, sunpeng wrote:

when I use the psql to send a sql, how to get current sql execution time?

#3bricklen
bricklen@gmail.com
In reply to: sunpeng (#1)
Re: how to get current sql execution time?

On Thu, Oct 14, 2010 at 3:47 PM, sunpeng <bluevaley@gmail.com> wrote:

when I use the psql to send a sql, how to get current sql execution time?

At the psql prompt:

# \timing
Timing is on.

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: sunpeng (#1)
Re: how to get current sql execution time?

On 10/14/2010 03:47 PM, sunpeng wrote:

when I use the psql to send a sql, how to get current sql execution time?

http://www.postgresql.org/docs/9.0/interactive/app-psql.html

"\timing [ on | off ]

Without parameter, toggles a display of how long each SQL statement
takes, in milliseconds. With parameter, sets same. "

--
Adrian Klaver
adrian.klaver@gmail.com

#5John R Pierce
pierce@hogranch.com
In reply to: sunpeng (#1)
Re: how to get current sql execution time?

On 10/14/10 3:47 PM, sunpeng wrote:

when I use the psql to send a sql, how to get current sql execution time?

\timing [{on|off}]

either toggles or sets on and off. when timing is on, it displays
query time.

#6Craig Ringer
craig@2ndquadrant.com
In reply to: sunpeng (#1)
Re: how to get current sql execution time?

On 15/10/2010 6:47 AM, sunpeng wrote:

when I use the psql to send a sql, how to get current sql execution time?

In addition to \timing as others have mentioned, you can use:

EXPLAIN ANALYZE [your-sql-here];

to get the server to tell you how it executed your SQL. If you do this,
the server won't return the query results, it'll instead return query
plan and timing data. Because of that, EXPLAIN ANALYZE doesn't include
the time it takes to transfer the results to the client, only the time
the server took to execute the query and how it executed it.

--
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/