When I do long running queries, I tend to use tmux and a psql console. It will not show me any output of when some operation was started or completed.
How can I get the psql console to show some timestamps?
Clarification:
I'm hoping for a non-scripting solution, just in the psql console. (Or does nobody use that console?) I'm maybe naive but still trying to do most of the database stuff using the database itself and its tools (using procedures, etc.)
Best Answer
There are various options for retrieving timing information while using
psql
.\timing
command.to insert the date in the output.
For both 2 and 3 you can supply arguments to
date
to get the date in the format you want.psql
non-interactively, you can pipe the output throughts
(from moreutils) or throughawk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'
(GNU's version of awk is needed) to prepend a timestamp to each line of output.