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 1ez11R-0002cA-6N for pgsql-admin@arkaria.postgresql.org; Thu, 22 Mar 2018 14:16:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ez11P-0006iG-Sr for pgsql-admin@arkaria.postgresql.org; Thu, 22 Mar 2018 14:16:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ez11P-0006i5-Hl for pgsql-admin@lists.postgresql.org; Thu, 22 Mar 2018 14:16:51 +0000 Received: from omr1.cc.ipv6.vt.edu ([2607:b400:92:8300:0:c6:2117:b0e] helo=omr1.cc.vt.edu) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ez11J-0005lS-16 for pgsql-admin@lists.postgresql.org; Thu, 22 Mar 2018 14:16:50 +0000 Received: from mr6.cc.vt.edu (mr6.cc.vt.edu [IPv6:2607:b400:92:8500:0:af:2d00:4488]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id w2MEGgrb014564 for ; Thu, 22 Mar 2018 10:16:43 -0400 Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by mr6.cc.vt.edu (8.14.7/8.14.7) with ESMTP id w2MEGbPu007339 for ; Thu, 22 Mar 2018 10:16:42 -0400 Received: by mail-qk0-f197.google.com with SMTP id a207so5415961qkb.23 for ; Thu, 22 Mar 2018 07:16:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=RA0xdIw+TFUEnrOTz0+L/Hi92+SXf5Em/8znLekbi8w=; b=YArHT6Y31NPkTjbIPt59zRNyrxwUxwnihd5MNLLagFbdojxCfvdtNArfca7j4GqfcN M1EWVyWh6LJ8rI6v++fkpGw2P95lForIxQ9y2u8Q8Bp5pSLEcvZkV8n7+0aJQ7pP+i6X xeIlVnF6sTp17eEtAK+iWbEvfogKpZGyMBsWHrYJ/9FDK16eVwESvaQguF5PDobPFqs6 ImIjCkxirj43vPo8giGiwSLnP4hUVFlNiKDi6Apxo79tlUUpKSFSHYgNlB4Ab45dM/YM fchbdkZO5pxrhCpDhqxRx0ogANcrarD7gsJUPTwEvcfGGJ+vVxk53kJJbiioP7DQmZ4S 9Slg== X-Gm-Message-State: AElRT7FOwUqAA72Gg2FUGGUJf6i4MwYPqUDVsQBjJxMaQ9j01sXPuKKv MzQONCFM3b4RhHOaevPBhyulurhmM8FZSa4OquiX9lT+oKYHrV1bqvgTPLo4kXLgdMjFWS7EGoc nMTDoKvXhJQxdqfwxHzyW1ID2/e4JaZXPlBQ4hZ2TOGKimJLYvoicCGbVPZ9kSRUIXXv2/aFPmz AJWCQQYh/b X-Received: by 10.200.41.237 with SMTP id 42mr24893257qtt.159.1521728197537; Thu, 22 Mar 2018 07:16:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELtpgNShSJJeJwffU/95ALxlPCjQttBRtiXHaO5Ip+K3RPaqeZc8Oau2sndmgi8MjVZO+QxPdQ== X-Received: by 10.200.41.237 with SMTP id 42mr24893229qtt.159.1521728197302; Thu, 22 Mar 2018 07:16:37 -0700 (PDT) Received: from stell.cns.vt.edu ([2001:468:c80:2102:807a:2094:4aa7:2cdf]) by smtp.gmail.com with ESMTPSA id y41sm4819581qty.90.2018.03.22.07.16.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:16:36 -0700 (PDT) Subject: Re: pg_stat_activity doubts To: Debraj Manna Cc: pgsql-admin@lists.postgresql.org References: <12be0586-aad1-4b4d-57f6-05514c52627e@vt.edu> From: Ray Stell Message-ID: <81a8bd42-a869-b4b3-62d0-d7c70e2d94c1@vt.edu> Date: Thu, 22 Mar 2018 10:16:34 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------CD5126B38FB545BF91A95053" 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. --------------CD5126B38FB545BF91A95053 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 3/22/18 10:01 AM, Debraj Manna wrote: > Thanks Ray . > > Any thoughts on my query #3? I would do an strace on the pid to see what is underneath.  Might give a clue where to look in the code. > > On Thu 22 Mar, 2018, 7:13 PM Ray Stell, > wrote: > > On 3/22/18 8:45 AM, Debraj Manna wrote: > >> Hi >> >> Can someone resolve my below doubts about pg_stat_activity :- >> >> 1. Can someone let me know how pg_stat_activity is populated? If >> I am executing a query like `Select * from pg_stat_activity` >> does it produce the details from some snapshot maintained by >> postgres or it checks the current connections open in >> postgres to provide the details? >> 2. Can some let me know what does the state IDLE denotes in the >> row of pg_stat_activity? Is it like it checks all the open >> connections to postgres and if the connection is not >> executing any query then IDLE denotes the last query executed >> by the connection? >> 3. In the output of select * from pg_stat_activity I am seeing >> rows with state IDLE and the query_start_date more than 2 >> days old? What does this signify ? Should I be worried about >> this? >> 4. >> > --------------CD5126B38FB545BF91A95053 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 3/22/18 10:01 AM, Debraj Manna wrote:

Thanks Ray .

Any thoughts on my query #3?

I would do an strace on the pid to see what is underneath.  Might give a clue where to look in the code. 


On Thu 22 Mar, 2018, 7:13 PM Ray Stell, <stellr@vt.edu> wrote:

On 3/22/18 8:45 AM, Debraj Manna wrote:

Hi

Can someone resolve my below doubts about pg_stat_activity :-

  1. Can someone let me know how pg_stat_activity is populated? If I am executing a query like `Select * from pg_stat_activity` does it produce the details from some snapshot maintained by postgres or it checks the current connections open in postgres to provide the details?
  2. Can some let me know what does the state IDLE denotes in the row of pg_stat_activity? Is it like it checks all the open connections to postgres and if the connection is not executing any query then IDLE denotes the last query executed by the connection?
  3. In the output of select * from pg_stat_activity I am seeing rows with state IDLE and the query_start_date more than 2 days old? What does this signify ? Should I be worried about this?
  4.  


--------------CD5126B38FB545BF91A95053--