Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOZ0K-00073q-Mz for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Aug 2022 06:27:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOZ0I-0006iP-Bo for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Aug 2022 06:27:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOZ0I-0006iE-0U for pgsql-hackers@lists.postgresql.org; Thu, 18 Aug 2022 06:27:42 +0000 Received: from smtp-fw-80006.amazon.com ([99.78.197.217]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOZ0D-0005E3-O8 for pgsql-hackers@lists.postgresql.org; Thu, 18 Aug 2022 06:27:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660804058; x=1692340058; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=65eyKOqbDwHnIeXsCAaEdwCsyjIquyqaNQM7WXlS4LU=; b=XBpfGJJln26YbY8h6daHoRpSlhiRQngOaGFE5dAV2Wb1w9BHrZLXhtbo WPjfyw4WWmkPxu5+5j9Djj2nNnrGNPY3w9bygmxfFNKNa+52q/wdpnFeP PMxzeUS0O5TxRnGJhe7aO13gTgXmiohZOobTVLwDPDygzqm/D0vz2WeDz Y=; X-IronPort-AV: E=Sophos;i="5.93,245,1654560000"; d="scan'208";a="120483861" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-pdx-2b-02ee77e7.us-west-2.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2022 06:27:21 +0000 Received: from EX13D03EUC003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2b-02ee77e7.us-west-2.amazon.com (Postfix) with ESMTPS id 82AE1419CD; Thu, 18 Aug 2022 06:27:19 +0000 (UTC) Received: from [192.168.13.168] (10.43.162.158) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Thu, 18 Aug 2022 06:27:15 +0000 Message-ID: <7f622949-2d78-c030-e7e0-cdee5f6cf79b@amazon.com> Date: Thu, 18 Aug 2022 08:27:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: shared-memory based stats collector - v70 To: Greg Stark CC: Andres Freund , Tom Lane , Melanie Plageman , Kyotaro Horiguchi , Justin Pryzby , Thomas Munro , "David G. Johnston" , PostgreSQL Hackers References: <20220317073652.kz3uuh6le6vbfod4@alap3.anarazel.de> <20220406030008.2qxipjxo776dwnqs@alap3.anarazel.de> <1736122.1658333315@sss.pgh.pa.us> <83D73EC0-E3ED-4C98-A528-5E122278D553@anarazel.de> <5db2b670-f3df-57ea-bdc6-962a582ff2e4@amazon.com> <0befffb3-8323-f2cd-915f-0ab64396f500@amazon.com> <1c56f4c6-61ce-d131-553c-297326e20bf1@amazon.com> Content-Language: en-US From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.43.162.158] X-ClientProxiedBy: EX13D49UWB003.ant.amazon.com (10.43.163.121) To EX13D03EUC003.ant.amazon.com (10.43.164.192) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 8/17/22 9:46 PM, Greg Stark wrote: > On Tue, 16 Aug 2022 at 08:49, Drouvot, Bertrand wrote: >> >> + if (p->key.kind != PGSTAT_KIND_RELATION) >> + continue; > Hm. So presumably this needs to be extended. Either to let the caller > decide which types of stats to return or to somehow return all the > stats intermixed. In my monitoring code I did the latter because I > didn't think going through the hash table repeatedly would be very > efficient. But it's definitely a pretty awkward API since I need a > switch statement that explicitly lists each case and casts the result. What I had in mind is to provide an API to retrieve stats for those that would need to connect to each database individually otherwise. That's why I focused on PGSTAT_KIND_RELATION that has PgStat_KindInfo.accessed_across_databases set to false. I think that another candidate could also be PGSTAT_KIND_FUNCTION. I think that's the 2 cases where a monitoring tool connected to a single database is currently missing stats related to databases it is not connected to. So what about 2 functions? one to get the stats for the relations and one to get the stats for the functions? (And maybe a view on top of each of them?) Regards, -- Bertrand Drouvot Amazon Web Services: https://aws.amazon.com