Re: how to determine what a process is doing

From: Jan Wieck <janwieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alex Howansky <alex(at)wankwood(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: how to determine what a process is doing
Date: 2000-12-03 23:07:43
Message-ID: 200012032307.SAA08586@jupiter.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Alex Howansky <alex(at)wankwood(dot)com> writes:
> > Is there any way to determine exactly what a postgres process is
> > doing at any time? The output from the ps command only shows "INSERT" or
> > "SELECT", and not the full query string.
>
> There isn't any really nice solution at the moment, but you could run
> the postmaster with -d2 to cause writing of all queries to the
> postmaster's log file (ie, its stdout/stderr). You'd probably also want
> to compile with ELOG_TIMESTAMPS defined (see include/config.h) to get
> timestamps and process PIDs included in the log. That'd give you info
> to correlate against what "top" shows.

If you compiled postgres with -g (what I do by default :-)
you could use this little script:

#!/bin/sh

gdb <<_EOF_
file /usr/home/pgsql/bin/postgres
attach $1
break pg_exec_query_string
commands 1
silent
print query_string
continue
end
continue
_EOF_

OK, could have some error checking and so, but it's a quick
hack - not a final solution.

Find the PID of a backend you want to examine and give it as
argument to the script. It'll then attach to the backend and
dump all queries sent from PHP until you hit ^C. It'll detach
again and the PHP script will never know.

If you redirect it's output to a file, just wait a few
seconds and hit ^C, there will not even be much delay for the
PHP. So the user might not notice too.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message GH 2000-12-03 23:40:24 Re: Re[2]: [Please vote for postgresql!!!]
Previous Message Jan Wieck 2000-12-03 22:41:14 Re: Unanswered questions about Postgre