Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEu2o-00AM66-3y for pgsql-general@arkaria.postgresql.org; Sat, 23 Nov 2024 17:35:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tEu2l-002Na6-23 for pgsql-general@arkaria.postgresql.org; Sat, 23 Nov 2024 17:35:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEu2j-002NZx-CN for pgsql-general@lists.postgresql.org; Sat, 23 Nov 2024 17:35:38 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEu2f-003TUH-8M for pgsql-general@postgresql.org; Sat, 23 Nov 2024 17:35:36 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 2C4FB25400DC; Sat, 23 Nov 2024 12:35:30 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Sat, 23 Nov 2024 12:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1732383330; x=1732469730; bh=c8SpJYyIMp4LklapmVpxBh5mvxpFs8KnYTpI5IXqqGU=; b= bf1fWB5rLymzHvCrAdgDlqg6lFOcQ4e8H5457sao1yzWRpcrBezef2TvQYjWqzYr Fldr+WLkQvp99FYwFBkA0uJqkktZkZZXs9oqhDBNuqE6pnsnodUNGaLfU1MgoNA6 rBV9mK4zMlpu/8ukiwiwk9BP6sWm/JJtF6TAA0VvEAn6AOnarnnAuH/CE1F2vJTN m2b5ydQcOqlpRWNJEVLTfuo3zR2CoIedGQtOabbBmDJtWcBLGpyMgkfw5fgD8iMI gylOuyyOIhExwHeTwLuRPFd28s2JQ8it2lGl+airgfHt13R4CEiHsYK4MOQHxrTu BV8jPf81aSl0iqolM5CjEA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1732383330; x= 1732469730; bh=c8SpJYyIMp4LklapmVpxBh5mvxpFs8KnYTpI5IXqqGU=; b=F BUpAG5R/HwjzJ6oSxAhlNOCBEscKmEXinAzj2VYLi8T2tQ4tBDlPLmiGpgr6BYff cYjL5Lcc7o8gtPNly1DIuFiT4HsYJ40nL/4+uIT3rRLo+Vkz82CO7kPNNsR5sOn7 H4OEdId3WCl+TYTyCRaIbwYaCKmSEAbvCxjglYCx6dF1Q8jGhULE+fta7AC/Paw4 RbT7J4h8BzTQZupOFay+OF0qg3d+TTC9vUQDgjpuUfWXUZIb4lDUeO2ZgN+dfGLS PNlpnD3t0enmQDJ0nIID5Y9oId+sIEZhm+I/CIxa7CD5qocpCt5IFRxuDozyFjAE Vlq0ljHxkoGElkXxZw6yA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrgedugddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdej necuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepfeegfeeiuedtgffgteeg gfehkeejheetieeliefgteeikeejvdeiveeigfehvedtnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghk lhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepshgsohhulhgrnhhgvghrvdelsehgmhgrihhlrdgtohhmpdhrtghpthht oheprhgrhiesrhhoughonhhnvghllhdrihgvpdhrtghpthhtohepphhgshhqlhdqghgvnh gvrhgrlhesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 23 Nov 2024 12:35:29 -0500 (EST) Message-ID: <60f946c9-8c68-4c40-a634-8483a1a1458c@aklaver.com> Date: Sat, 23 Nov 2024 09:35:28 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Database stats ( pg_stat_database.stats_reset ) get reset on daily basis - why? To: Steeve Boulanger , Ray O'Donnell Cc: pgsql-general References: <6a157286-5948-48ac-bc50-7bb4e65ee5e5@aklaver.com> <38725031-5e80-46ee-b403-a92107b24c39@aklaver.com> <1e2db3f5-00f4-4ec2-800f-46136c2fad59@aklaver.com> <1270021b-c5b5-4ca8-b48d-7dfb163bb6f7@aklaver.com> <9a0d0e80-13e1-421a-9d84-da000fe4433a@aklaver.com> <01020193592431ad-0fedca70-38e9-4fd0-bf49-f5bbf628c76e-000000@eu-west-1.amazonses.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/23/24 05:16, Steeve Boulanger wrote: >> Here (Ireland) we sometimes say "common-or-garden variety".... It means a normal, everyday variety. :-) > > I'm afraid that my Irish dialect is limited to "sláinte" only ;-) In > any case, thanks for taking the time to help with this issue. I'm > still investigating, but I think that calling the "ghostbusters" is > moving up the list now lol. One possible scenario: log_min_messages = info log_min_error_statement = info log_statement = 'all' psql -d test -U postgres -p 5432 CREATE OR REPLACE FUNCTION public.admin_func() RETURNS void LANGUAGE plpgsql AS $function$ BEGIN PERFORM pg_stat_reset(); RAISE NOTICE 'Reset statistics'; END; $function$ select datname, stats_reset from pg_stat_database; datname | stats_reset --------------+------------------------------- NULL | NULL postgres | NULL template1 | NULL template0 | NULL test | 2024-11-23 09:21:49.421552-08 task_manager | NULL test_psql | NULL production | NULL pp_archive | NULL farm_db | NULL select admin_func(); NOTICE: Reset statistics admin_func ------------ (1 row) select datname, stats_reset from pg_stat_database; datname | stats_reset --------------+------------------------------- NULL | NULL postgres | NULL template1 | NULL template0 | NULL test | 2024-11-23 09:26:30.749257-08 task_manager | NULL test_psql | NULL production | NULL pp_archive | NULL farm_db | NULL 2024-11-23 09:26:30.749 PST [14501] postgres@test LOG: statement: select admin_func(); 2024-11-23 09:26:30.749 PST [14501] postgres@test NOTICE: Reset statistics 2024-11-23 09:26:30.749 PST [14501] postgres@test CONTEXT: PL/pgSQL function admin_func() line 4 at RAISE 2024-11-23 09:26:30.749 PST [14501] postgres@test STATEMENT: select admin_func(); The issue being that the pg_stat_reset() is buried in a function and does not show up on its own. The RAISE NOTICE alerts in my logs just so I could find the function easily. It could be there is a function or functions in your setup doing something similar. > > > On Sat, Nov 23, 2024 at 7:09 AM Ray O'Donnell wrote: >> >> On 23/11/2024 13:06, Steeve Boulanger wrote: >> >> >>> The above is some garden variety select? >> >> Not 100% sure what the expression "garden variety select" means lol, but I'll take a guess that it means an "select from an in-house application" .. and yes it is. >> >> >> Here (Ireland) we sometimes say "common-or-garden variety".... It means a normal, everyday variety. :-) >> >> Ray. >> >> >> >> >> -Steeve >> >> On Fri, Nov 22, 2024 at 11:18 AM Adrian Klaver wrote: >>> >>> On 11/21/24 15:50, Steeve Boulanger wrote: >>>> > 1) Do the 77 share some trait the other 80 don't. >>>> >>>> No pattern found yet .. but still verifying a few things >>>> >>>> > 2) Do the OS system logs reveal anything? >>>> >>>> Nothing found in syslog >>>> >>>> > 3) What was happening in the databases just prior to the time the stats >>>> reset? >>>> >>>> Here's an example (log extracts) for a stats reset occurrence: >>>> >>>> select datname, stats_reset, now()-stats_reset as since_reset >>>> from pg_stat_database >>>> where ( now()-stats_reset ) < interval '1 day' >>>> order by 3 limit 1; >>>> >>>> datname | stats_reset | since_reset >>>> ----------------+-------------------------------+----------------- >>>> MyDB | *2024-11-21 13:48:34.332*785+00 | 00:00:22.266304 >>>> >>>> <--LOGS--> >>>> 2024-11-21 13:48:34.324 UTC pid=[322035][2] db=[MyDB] usr=[user1] >>>> client=[host1] app=[[unknown]]LOG: connection authorized: user=user1 >>>> database=MyDB applicatio >>>> n_name=app1 <..> >>> >>> What is the [2] referring to? >>> >>>> >>>> <.. no calls at "2024-11-21 13:48:34.332" - WHY?? ..> >>> >>> My guess is the difference in time it takes to log the action and set >>> the log timestamp. Whereas the stats_reset value is the timestamp when >>> the stats system actually did the reset. >>> >>>> >>>> 2024-11-21 13:48:34.336 UTC pid=[322035][3] db=[MyDB] usr=[user1] >>>> client=[host1] app=[app1]LOG: duration: 1.071 ms parse : >>>> SELECT <..> >>> >>> The above is some garden variety select? >>> >>> >>> >>> -- >>> Adrian Klaver >>> adrian.klaver@aklaver.com >>> >> >> >> -- >> Raymond O'Donnell // Galway // Ireland >> ray@rodonnell.ie -- Adrian Klaver adrian.klaver@aklaver.com