Search Postgresql Archives

Re: pg_catalog.pg_stat_activity and current_query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 1 March 2011 09:36, Alex <alexadri83@xxxxxxxxxxx> wrote:
Good morning,

I'm trying to make a Postgre profiler reading
pg_catalog.pg_stat_activity.
But when I read that view... I always find my query.

Example:

ResultSet rs = st.executeQuery("SELECT query_start,current_query FROM
pg_catalog.pg_stat_activity where xact_start is not null");
while(rs.next()) {
ÂString sQuery = rs.getString("current_query");
ÂqStart = rs.getTimestamp("query_start");
Âif(!qStart.equals(qStart_last)){
 Âdisplay.append(sQuery+'\n');
 ÂqStart_last=(Timestamp)qStart.clone();
Â}
}

Always prints "SELECT query_start,current_query FROM
pg_catalog.pg_stat_activity where xact_start is not null" :)

I'd like to discard my query... any ideas?

Thanks


If you want just to get rid of you query, add this to your query:

and procpid <> pg_backend_pid()

so you will have something like this:

SELECT query_start,current_query FROM
pg_catalog.pg_stat_activity where xact_start is not null and procpid <> pg_backend_pid()

regards
SzymonÂ


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux