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
  • 440,273
  • 77
  • 685
  • 758
David S
  • 10,941
  • 10
  • 50
  • 91

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
  • 3,636
  • 2
  • 25
  • 40