pg_catalog.pg_stat_activity and current_query

From: Alex <alexadri83(at)virgilio(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: pg_catalog.pg_stat_activity and current_query
Date: 2011-03-01 08:36:48
Message-ID: cb45f32a-9b25-4402-afb6-fd63a58b6f75@v31g2000vbs.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Orhan Kavrakoglu 2011-03-01 08:51:01 Re: how to avoid repeating expensive computation in select
Previous Message Vibhor Kumar 2011-03-01 07:48:08 Re: restore a server backup