in Databases

The dot psqlrc file (~/.psqlrc)

The ~/.psqlrc file allows you to specify session level settings consistently to be used when you connect to Postgres via the command line. This file goes in the user home directory that you are connecting as. There are a few settings I like to set on the servers that make the output similar to MySQL, which is what I am most familiar with. They are listed below.  We use Puppet to distribute this file on our systems to give a consistent user experience on the command line for the Postgres user.

Value: \timing
Description: This turns on the tracking and display of the duration a query takes to execute. This is something that MySQL does by default that Postgres does not waste the cpu cycles on to calculate unless you tell it to.

Value: \pset border 2
Description: This fills the outside border in the same way that MySQL does. It is strictly a visual preference.

Value: \set pager off
Description: This turns the pager off which is generally what I prefer. Pager being on treats query output like the “more” command.

Write a Comment