Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK8Rs-0006Qu-0R for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 20:59:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gK8Rp-0003Ro-Rh for pgsql-general@arkaria.postgresql.org; Tue, 06 Nov 2018 20:59:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gK8Rp-0003Or-G4 for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 20:59:41 +0000 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gK8Rm-0000jU-Ct for pgsql-general@lists.postgresql.org; Tue, 06 Nov 2018 20:59:41 +0000 Received: by mail-ot1-x342.google.com with SMTP id m15so12804603otl.7 for ; Tue, 06 Nov 2018 12:59:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=Od1vcESnxt70oC5eCtO4kAHRiUWUg3QIh01CRxujm78=; b=MX/5KTEG3ELRZ5x4RqA9nvHrPHggaAMG/FgUQWemYIlZ2ZmpysSFYYnpYQ69Bna83y sMH98deozOwl5DUlZYfomJH5qQfq3Q6R2DIVEF+p4poF99K8RR8rKNFbuGWAYIyUrlgS M0TKwjpScsGKJscmiZ3kYLL/vcA1Um73gMqcUfVfRgg2poCz72hKeFj6PsTsKxAwPdb+ JMktxs35CJmy5/hk5pmveQPFA9EXzoMvJObUpU2yb+ulcvsrIjEEg0aF3qQ+5IfT8OGw n8vHhViN9oxNXtap+kkOhEEPmVmjT4fS7EpkS+A8QqHRdATulSSrBqGHDJd2T1JPU5zf q8JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Od1vcESnxt70oC5eCtO4kAHRiUWUg3QIh01CRxujm78=; b=aOD+FN2G/jB9spF/Bew2630XsDGg53J6l2q0m/NrrVZMP4fMVAgwnzEyDh8uCFyLg0 vtwR6W6QGNOcZ0Cv/hUTtvG4wNnddgP1JZB6OOfhpE9PFfukBxHt/hFqYWc4bNNv57eG fLxzitEGJX7th+lCY/1FvGA3LRs8KbMT0xU0imBJZJjpjUZSXWKbfFbT1hZ4/hdsHQ16 Eo75BbDvvY0x/fUML5JjRMOEn9SLKdWaktQN3TzoU74hmVlcf6OQA72tRXDiWex32zsM aWApXgKGlQlshuPeC2bH1JKIzAQx9By1Kwh3I9/9/wWLwSut33LYUydFBaTn/xLnyRtX XMBg== X-Gm-Message-State: AGRZ1gJ9BpqcFLZhXIkfC/jwqw1Uo1efMZu4POMcLoBI3cqFrvbqPpi3 NMr8DKRbNJGjLwW5vprb2vqIjDEO X-Google-Smtp-Source: AJdET5etzgq2sNq5WNxj01n4cO2w0t0wuKung0cQT98aVVVXE/+x0qoLM/sjPNAeS0cf2o2XRkp+zg== X-Received: by 2002:a9d:a2e:: with SMTP id 43mr15441189otg.8.1541537975831; Tue, 06 Nov 2018 12:59:35 -0800 (PST) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id w31sm1024535otb.57.2018.11.06.12.59.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 12:59:35 -0800 (PST) Subject: Re: Idle query that's not ""? To: pgsql-general@lists.postgresql.org References: <579485f2-10a5-50bc-ef15-f731e756e970@gmail.com> From: Ron Message-ID: <903cb6c0-8c04-917a-8c5e-21396e53a341@gmail.com> Date: Tue, 6 Nov 2018 14:59:34 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------87C9E0E5D28849AD6AA5D8E0" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------87C9E0E5D28849AD6AA5D8E0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Right.  But when does the query text become ""?  Or has that become obsolete? (We recently migrated from 8.4.) On 11/06/2018 02:53 PM, Hellmuth Vargas wrote: > Hi > In the documentation describes the data in this field: > > https://www.postgresql.org/docs/10/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW > > "Text of this backend's most recent query. If |state| is |active| this > field shows the currently executing query. In all other states, it shows > the last query that was executed. " > > > El mar., 6 de nov. de 2018 a la(s) 15:46, Ron (ronljohnsonjr@gmail.com > ) escribió: > > Hi, > > v9.6.6 > > Why do these idle queries (pids 8357, 11260 and 11355) "remember" the > queries they ran instead of having the text ""? > > postgres=# select pid, >            xact_start as txn_start, >            to_char(EXTRACT(epoch FROM now() - query_start), > '999,999.0000') as query_age_secs, >            state, >            cast (query as char(20)) > from pg_stat_activity > where datname <> 'postgres' > order by query_start; > ; > >  pid  |           txn_start           | query_age_secs | state  > |        query > ------+-------------------------------+----------------+--------+---------------------- > 26538 | 2018-11-06 14:40:55.053842-05 | 3,451.9853  | active | SELECT  > to_char(b.pr > 27497 | 2018-11-06 14:59:26.946854-05 | 2,340.5871  | active | SELECT  > to_char(b.pr > 29110 | 2018-11-06 14:59:50.479934-05 | 2,317.1725  | active | SELECT  > to_char(b.pr > * 8357 |                               | 1,324.1356  | idle   | > SELECT  CAST(c.ecid* >  9016 | 2018-11-06 15:34:51.535476-05 | 215.8391  | active | SELECT  > to_char(b.pr >  9810 | 2018-11-06 15:35:00.483292-05 | 206.7676  | active | SELECT  > to_char(b.pr > *11260 |                               | 190.0814  | idle   | WITH > configs AS (SEL* > 12800 | 2018-11-06 15:35:49.540631-05 | 157.9880  | active | SELECT  > to_char(b.pr > *11355 |                               | 42.9772  | idle   | SELECT > CASE WHEN typ* > 22618 | 2018-11-06 15:38:02.317146-05 | 25.3219  | active | SELECT  > to_char(b.pr > 23176 | 2018-11-06 15:38:12.90985-05  | 14.7325  | active | SELECT  > to_char(b.pr > 23566 | 2018-11-06 15:38:28.802919-05 | .6116  | active | select > tms.TRIGGER.T > 23588 | 2018-11-06 15:38:29.207373-05 | .2089  | active | select > cds.IMAGE_RPS > 23590 | 2018-11-06 15:38:29.233724-05 | .1814  | active | select > tms.TRIGGER.T > 23584 | 2018-11-06 15:38:29.046393-05 | .0442  | active | select > tms.MARK_SENS > 23595 | 2018-11-06 15:38:29.403969-05 | .0001  | active | select > JOB_STEP.JOB_ > (16 rows) > > > -- > Angular momentum makes the world go 'round. > > > > -- > Cordialmente, > > Ing. Hellmuth I. Vargas S. > Esp. Telemática y Negocios por Internet > Oracle Database 10g Administrator Certified Associate > EnterpriseDB Certified PostgreSQL 9.3 Associate > -- Angular momentum makes the world go 'round. --------------87C9E0E5D28849AD6AA5D8E0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Right.  But when does the query text become "<IDLE>"?  Or has that become obsolete? (We recently migrated from 8.4.)

On 11/06/2018 02:53 PM, Hellmuth Vargas wrote:
Hi
In the documentation describes the data in this field:

"Text of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed. "


El mar., 6 de nov. de 2018 a la(s) 15:46, Ron (ronljohnsonjr@gmail.com) escribió:
Hi,

v9.6.6

Why do these idle queries (pids 8357, 11260 and 11355) "remember" the queries they ran instead of having the text "<IDLE>"?

postgres=# select pid,
           xact_start as txn_start,
           to_char(EXTRACT(epoch FROM now() - query_start), '999,999.0000') as query_age_secs,
           state,
           cast (query as char(20))

from pg_stat_activity
where datname <> 'postgres'
order by query_start;
;
 
 pid  |           txn_start           | query_age_secs | state  |        query       
------+-------------------------------+----------------+--------+----------------------
26538 | 2018-11-06 14:40:55.053842-05 |    3,451.9853  | active | SELECT  to_char(b.pr
27497 | 2018-11-06 14:59:26.946854-05 |    2,340.5871  | active | SELECT  to_char(b.pr
29110 | 2018-11-06 14:59:50.479934-05 |    2,317.1725  | active | SELECT  to_char(b.pr
 8357 |                               |    1,324.1356  | idle   | SELECT  CAST(c.ecid
 9016 | 2018-11-06 15:34:51.535476-05 |      215.8391  | active | SELECT  to_char(b.pr
 9810 | 2018-11-06 15:35:00.483292-05 |      206.7676  | active | SELECT  to_char(b.pr
11260 |                               |      190.0814  | idle   | WITH configs AS (SEL
12800 | 2018-11-06 15:35:49.540631-05 |      157.9880  | active | SELECT  to_char(b.pr
11355 |                               |       42.9772  | idle   | SELECT CASE WHEN typ
22618 | 2018-11-06 15:38:02.317146-05 |       25.3219  | active | SELECT  to_char(b.pr
23176 | 2018-11-06 15:38:12.90985-05  |       14.7325  | active | SELECT  to_char(b.pr
23566 | 2018-11-06 15:38:28.802919-05 |         .6116  | active | select tms.TRIGGER.T
23588 | 2018-11-06 15:38:29.207373-05 |         .2089  | active | select cds.IMAGE_RPS
23590 | 2018-11-06 15:38:29.233724-05 |         .1814  | active | select tms.TRIGGER.T
23584 | 2018-11-06 15:38:29.046393-05 |         .0442  | active | select tms.MARK_SENS
23595 | 2018-11-06 15:38:29.403969-05 |         .0001  | active | select JOB_STEP.JOB_
(16 rows)


--
Angular momentum makes the world go 'round.


--
Cordialmente,

Ing. Hellmuth I. Vargas S.
Esp. Telemática y Negocios por Internet 
Oracle Database 10g Administrator Certified Associate
EnterpriseDB Certified PostgreSQL 9.3 Associate


--
Angular momentum makes the world go 'round.
--------------87C9E0E5D28849AD6AA5D8E0--