HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlCritical

How can I time SQL-queries using psql?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
cansqltimepsqlusinghowqueries

Problem

I would like to benchmark some SQL-queries agains my PostgreSQL database. Is there any way I can time SQL-queries using psql?

Solution

Timing can be turned on with \timing at the psql prompt (as Caleb already said).

If you are on 8.4 or above, you can add an optional on/off argument to \timing, which can be helpful if you want to be able to set timing on in .psqlrc - you can then set \timing on explicitly in a script where plain \timing would otherwise toggle it off

Context

StackExchange Database Administrators Q#3148, answer score: 80

Revisions (0)

No revisions yet.