Fork Me On GitLab

psql Tips

Psql Tip #055

The psql prompt can display the process ID of the backend currently connected to with the %p value.
laetitia=# \set PROMPT1 '%p #'
94162 #\! pgrep -fal postgres
1866 /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
1867 postgres: logger  ptr_munge= main_stack=
1869 postgres: checkpointer  ptr_munge= main_stack=
1870 postgres: background writer  ptr_munge= main_stack=
1871 postgres: walwriter  ptr_munge= main_stack=
1872 postgres: autovacuum launcher  ptr_munge= main_stack=
1873 postgres: stats collector  ptr_munge= main_stack=
1874 postgres: logical replication launcher  ptr_munge= main_stack=
94162 postgres: laetitia laetitia [local] idle ptr_munge= main_stack=
94162 #
This feature is available since Postgres 9.6.
See Postgres documentation for more information.
Try a new tipSee them all