0

I have a script file with several SQL statements in it. I know how to get the time to execute each statement. I am running it with the \i option from inside of psql. Is there a way to get or print the total time for the file? In other words, the combined time?

Using PostgreSQL 9.4.

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
David S
  • 11,931
  • 12
  • 52
  • 93

1 Answers1

1

Assuming bash friendly environment:

$ time psql <<connection settings>> < script.sql

Sample output:

$ time sleep 3

real    0m3.001s
user    0m0.000s
sys     0m0.000s

You are interested in "real" value. More on these values: What do 'real', 'user' and 'sys' mean in the output of time(1)?

Community
  • 1
  • 1
Radek Postołowicz
  • 4,091
  • 2
  • 27
  • 43