10

I work with PostgreSQL in the command line interface. I would like to activate a \timing command permanently for every database in the cluster so every time I connect to a database - this parameter is on. I searched in postgresql.conf file, but I haven't found anything like what I want to switch on.

My PostgreSQL is 9.5.4 on x86_64 Ubuntu 16.04.2.

asked Nov 22, 2016 at 11:37

1 Answer 1

15

\timing is specific to the client psql, not to the database server. You need to put that into the configuration file for psql which is ~/.psqlrc

See the manual for details: https://www.postgresql.org/docs/current/static/app-psql.html#AEN100589

psql attempts to read and execute commands from the system-wide startup file (psqlrc) and then the user's personal startup file (~/.psqlrc), after connecting to the database but before accepting normal commands

answered Nov 22, 2016 at 11:44
2
  • 2
    It worked. I created a file: touch ~/.psqlrc and added '\timing' string there. Commented Nov 22, 2016 at 12:53
  • 1
    To enable timing for all your psql sessions, run this in your shell (note the double backslash): echo '\\timing on' >> ~/.psqlrc Commented Apr 25, 2023 at 20:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.