Postgresql – set -x equivalent for the Postgres cli/console/prompt/repl

postgresqlpsql

Is there a "set -x" for the Postgres prompt/repl ?

In bash when you want to execute a set of commands, and come back to check it after lunch you can do

set -x
command1
command2
command3

and bash prints out the command to STDOUT just before it executes it.
this is helpful to see, what's taking a long time, which did line did it last execute, etc.

Similarly, inside the psql console, I also do sets of long running commands:

VACUUM FULL VERBOSE ANALYZE events;
REINDEX VERBOSE TABLE events;

Can I do

set -x
VACUUM FULL VERBOSE ANALYZE events;
REINDEX VERBOSE TABLE events;

so that when I come back from lunch I can see which one of my commands was the last one it did.

Best Answer

I guess you want \set ECHO queries.