1

When I execute

ps aux | grep postgres

or top | grep postgres

I get all my postgres processes with some information, the last column (command) has the following structure:

postgres: username db ip_address(xxxxx) QUERY_TYPE

For example:

postgres: postgres test 192.168.0.100(33195) SELECT

What does this number means (33195)?

I'm having troubles with my database and I want to know if this information could help me. Some queries are taking too long.

It is some kind of process dependency?

0

According to the postgresql docs,

On most Unix platforms, PostgreSQL modifies its command title as reported by ps, so that individual server processes can readily be identified

It appears to me that the 33195 in your example is the port on the possibly-remote system 192.168.0.100 that has connected with the postgres server. Confirm with something like netstat -an | grep 33195 .

Just found the git repository for postgresql where I traced the behavior to the DoBackend function, which updates the ps listing like this:

/*
 * Set process parameters for ps
 *
 * WARNING: On some platforms the environment will be moved around to
 * make room for the ps display string. So any references to
 * optarg or getenv() from above will be invalid after this call.
 * Better use strdup or something similar.
 */
init_ps_display(real_argc, real_argv, port->user, port->database,
                remote_host);

where remote_host was set earlier.

  • I might have stumbled onto the wrong git branch; see also this – Jeff Schaller Nov 10 '16 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.