PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Come mostrare WORK_MEM di connessioni PostgreSQL esterne?

Puoi entrare nel processo con un debugger a livello di sistema operativo.

Mostrerò come farlo su Linux:

$ psql "dbname=test options='-c work_mem=256MB' application_name=test"
psql (9.6.1)
Type "help" for help.

test=>  SELECT pg_backend_pid();
 pg_backend_pid
----------------
          21089
(1 row)

Ora posso entrare nel processo sulla macchina server:

$ gdb /path/to/postgres-9.6.1/bin/postgres 21089
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
...
(gdb) print work_mem
$1 = 262144
(gdb) detach
Detaching from program: /path/to/postgres-9.6.1/bin/postgres, process 21089
(gdb) quit

Non vorresti farlo su un sistema di produzione, poiché il backend è bloccato durante il debug.