How to echo statements in sourced file?

Started by Kynn Jonesover 17 years ago4 messagesgeneral
Jump to latest
#1Kynn Jones
kynnjo@gmail.com

Hi. I have a collection of SQL statements stored in a file that I run
periodically via cron. Running this "script" takes a bit too long, even for
a cron job, and I would like to profile it.
I learned from Andreas Kretschmer (in another thread, in the
pgsql-performance list) about the \timing directive, which is useful for
this.

Now, after turning timing on, when I "source" the script from within psql,
with

mydb=> \i /path/to/my/script

...I get output lines like this

Time: 38.519 ms

right in my psql terminal after each statement in the file gets executed.

But now I need a way to have these statements that are being timed
themselves echoed to the terminal. Is there a way to do this?

TIA!

Kynn

#2Harvey, Allan AC
HarveyA@OneSteel.com
In reply to: Kynn Jones (#1)
Re: How to echo statements in sourced file?

right in my psql terminal after each statement in the file gets executed.

But now I need a way to have these statements that are being timed themselves echoed to the terminal. Is there a way to do this?

start psql with the -a switch, I think.

Allan

The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient, use, disclosure or copying of this information is prohibited. If you have received this document in error, please advise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses contained in this email or any attachments.

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Kynn Jones (#1)
Re: How to echo statements in sourced file?

Kynn Jones escribi�:

But now I need a way to have these statements that are being timed
themselves echoed to the terminal. Is there a way to do this?

psql -e

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#4Kynn Jones
kynnjo@gmail.com
In reply to: Kynn Jones (#1)
Re: How to echo statements in sourced file?

Thank you all. From your replies I was able to figure out what I needed:
"\set ECHO queries"
Kynn

On Wed, Dec 3, 2008 at 7:14 PM, Kynn Jones <kynnjo@gmail.com> wrote:

Show quoted text

Hi. I have a collection of SQL statements stored in a file that I run
periodically via cron. Running this "script" takes a bit too long, even for
a cron job, and I would like to profile it.
I learned from Andreas Kretschmer (in another thread, in the
pgsql-performance list) about the \timing directive, which is useful for
this.

Now, after turning timing on, when I "source" the script from within psql,
with

mydb=> \i /path/to/my/script

...I get output lines like this

Time: 38.519 ms

right in my psql terminal after each statement in the file gets executed.

But now I need a way to have these statements that are being timed
themselves echoed to the terminal. Is there a way to do this?

TIA!

Kynn