pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Checking what is the current query running
6+ messages / 5 participants
[nested] [flat]

* Checking what is the current query running
@ 2006-07-25 08:15  Marco Bizzarri <marco.bizzarri@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Marco Bizzarri @ 2006-07-25 08:15 UTC (permalink / raw)
  To: pgsql-admin

Hi all.

I've a postgresql where sometimes a process can remaing running a
query for a very long time.

Aside from logging the queries, is there a way to know which query is
running in one particular moment?

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Checking what is the current query running
@ 2006-07-25 08:56  Shoaib Mir <shoaibmir@gmail.com>
  parent: Marco Bizzarri <marco.bizzarri@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Shoaib Mir @ 2006-07-25 08:56 UTC (permalink / raw)
  To: pgsql-admin

You have to enable "stats_command_string' in your postgresql.conf file:

stats_command_string = on

After that is done you can view queries running on database server like
this:

select current_query from pg_stat_activity;

You can also get the query execution times and which queries were run, in
the database server logs files by enabling the following in postgresql.conffile:

log_duration = on
log_statement = 'all'

Hope this helps...

Thanks,

Shoaib Mir
EnterpriseDB


On 7/25/06, Marco Bizzarri <marco.bizzarri@gmail.com> wrote:
>
> Hi all.
>
> I've a postgresql where sometimes a process can remaing running a
> query for a very long time.
>
> Aside from logging the queries, is there a way to know which query is
> running in one particular moment?
>
> Regards
> Marco
>
> --
> Marco Bizzarri
> http://notenotturne.blogspot.com/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Checking what is the current query running
@ 2006-07-25 09:34  Markus Wollny <Markus.Wollny@computec.de>
  0 siblings, 1 reply; 6+ messages in thread

From: Markus Wollny @ 2006-07-25 09:34 UTC (permalink / raw)
  To: pgsql-admin

Hi,

pg_stat_activity has some limitations however; if you use a lot of
dynamically generated complex queries, you might stumble over the 255
character limit of current_query in pg_stat_activity, statement-strings
longer than that are just cut off.

You can get some more information if you need it, using the GNU debugger
gdb: First you need to determine the PID of the PostgreSQL backend
that's running your query - I usually use top for that, but
pg_stat_activity does also give you that info (select procpid from
pg_stat_activity ...). Once you have the PID, you start the GNU debugger
with

gdb [path_to_postgres] [pid]
e.g. gdb /opt/pgsql/bin/postgres 551

Now issue the command 
	printf "%s\n", debug_query_string
to obtain the query string. To quit the debugger, just type "quit" and
confirm - the backend will keep processing the query uninterrupted.

Kind regards

   Markus





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Checking what is the current query running
@ 2006-07-25 10:15  Dilipkumar <dilipkumar_parikh@sifycorp.com>
  parent: Shoaib Mir <shoaibmir@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Dilipkumar @ 2006-07-25 10:15 UTC (permalink / raw)
  To: Shoaib Mir <shoaibmir@gmail.com>; pgsql-admin

HI,

Is there any way to log all the queries in  7.1.1 (older release).please help out guys.

Thanks & Regards
Dilipkumar
  ----- Original Message ----- 
  From: Shoaib Mir 
  To: Postgres 
  Sent: Tuesday, July 25, 2006 2:26 PM
  Subject: Re: [ADMIN] Checking what is the current query running


  You have to enable "stats_command_string' in your postgresql.conf file:

  stats_command_string = on

  After that is done you can view queries running on database server like this:

  select current_query from pg_stat_activity; 

  You can also get the query execution times and which queries were run, in the database server logs files by enabling the following in postgresql.conf file:

  log_duration = on
  log_statement = 'all'

  Hope this helps...

  Thanks,

  Shoaib Mir
  EnterpriseDB



  On 7/25/06, Marco Bizzarri <marco.bizzarri@gmail.com > wrote:
    Hi all.

    I've a postgresql where sometimes a process can remaing running a 
    query for a very long time.

    Aside from logging the queries, is there a way to know which query is
    running in one particular moment?

    Regards
    Marco

    --
    Marco Bizzarri
    http://notenotturne.blogspot.com/

    ---------------------------(end of broadcast)---------------------------
    TIP 9: In versions below 8.0, the planner will ignore your desire to
           choose an index scan if your joining column's datatypes do not 
           match



********** DISCLAIMER **********
Information contained and transmitted by this E-MAIL is proprietary to 
Sify Limited and is intended for use only by the individual or entity to 
which it is addressed, and may contain information that is privileged, 
confidential or exempt from disclosure under applicable law. If this is a 
forwarded message, the content of this E-MAIL may not have been sent with 
the authority of the Company. If you are not the intended recipient, an 
agent of the intended recipient or a  person responsible for delivering the 
information to the named recipient,  you are notified that any use, 
distribution, transmission, printing, copying or dissemination of this 
information in any way or in any manner is strictly prohibited. If you have 
received this communication in error, please delete this mail & notify us 
immediately at admin@sifycorp.com


Watch the latest updates on Mumbai, with video coverage of news, events,
Bollywood, live darshan from Siddhivinayak temple and more, only on
www.mumbailive.in

Watch the hottest videos from Bollywood, Fashion, News and more only on
www.sifymax.com

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Checking what is the current query running
@ 2006-07-25 12:09  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Markus Wollny <Markus.Wollny@computec.de>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2006-07-25 12:09 UTC (permalink / raw)
  To: Markus Wollny <Markus.Wollny@computec.de>; +Cc: pgsql-admin

"Markus Wollny" <Markus.Wollny@computec.de> writes:
> pg_stat_activity has some limitations however; if you use a lot of
> dynamically generated complex queries, you might stumble over the 255
> character limit of current_query in pg_stat_activity, statement-strings
> longer than that are just cut off.

The limit has been ~1K, not 255, for a long time (since 8.0).

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Checking what is the current query running
@ 2006-07-25 15:10  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Dilipkumar <dilipkumar_parikh@sifycorp.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2006-07-25 15:10 UTC (permalink / raw)
  To: Dilipkumar <dilipkumar_parikh@sifycorp.com>; +Cc: Shoaib Mir <shoaibmir@gmail.com>; pgsql-admin

"Dilipkumar" <dilipkumar_parikh@sifycorp.com> writes:
> Is there any way to log all the queries in  7.1.1 (older release).please =
> help out guys.

The very best advice anyone could give you is to stop using 7.1.anything
and get onto a more modern PG release as soon as possible.  7.1 *will*
eat your data eventually, and even in the 7.1 series, there are later
bug-fix releases than 7.1.1 ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2006-07-25 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-07-25 08:15 Checking what is the current query running Marco Bizzarri <marco.bizzarri@gmail.com>
2006-07-25 08:56 ` Shoaib Mir <shoaibmir@gmail.com>
2006-07-25 10:15   ` Dilipkumar <dilipkumar_parikh@sifycorp.com>
2006-07-25 15:10     ` Tom Lane <tgl@sss.pgh.pa.us>
2006-07-25 09:34 Re: Checking what is the current query running Markus Wollny <Markus.Wollny@computec.de>
2006-07-25 12:09 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox