getting elapsed query times

From: Aaron Burnett <aburnett(at)bzzagent(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: getting elapsed query times
Date: 2009-01-03 14:36:03
Message-ID: C584E203.4D475%aburnett@bzzagent.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi,

I think I am experiencing the "forest through the trees" type of scenario
here.

In a nightly cron I have a shell script that executes a couple of things for
our data warehouse.

I call it like this from the cron:

/home/postgres/DB1/sys/createDB1.sh >> /home/postgres/DB1/logs/createDB1.log
2>&1

within the script:

The first calls a function which essentially calls a handful of views.

psql -d DB1 -c 'select execute_function_foo();'

The second just calls a simple sql script.

psql -d DB1 -f /path/to/sql/script.sql

What I am trying to get is the elapsed time logged for each individual query
or view that the function calls, as though I entered "\timing" from within
psql.

like:

db1=# \timing
Timing is on.
db1=# select count(*) from table_foo;
count
---------
5232924
(1 row)

Time: 3248.064 ms

except I need that to show up in the nightly log for each sql statement.

running postgresql 8.2.5 with RHEL 4

Thanking you in advance for any assistance.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kenneth Lundin 2009-01-03 15:37:02 restore problem with pg_dumpall dump (password authentication fail)
Previous Message Reg Me Please 2009-01-03 11:07:20 Re: auto insert data every one minute