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 1tEBO3-005jje-Hl for pgsql-general@arkaria.postgresql.org; Thu, 21 Nov 2024 17:54:39 +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 1tEBO1-0000r5-HS for pgsql-general@arkaria.postgresql.org; Thu, 21 Nov 2024 17:54:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEBO0-0000qx-6A for pgsql-general@lists.postgresql.org; Thu, 21 Nov 2024 17:54:37 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tEBNx-0035Wr-5f for pgsql-general@postgresql.org; Thu, 21 Nov 2024 17:54:34 +0000 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 99FA411400E1; Thu, 21 Nov 2024 12:54:31 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 21 Nov 2024 12:54:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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=1732211671; x=1732298071; bh=tvbfdd3/mch0/vh9IREtEsq17/DUPMcDkTWF9RDb5e8=; b= NoEQHK6ZOiyclonruUvQ5KcSAmCQIf8mDWrD80n1+mk+Bta/ffSMKlQYQuRZdcU/ P0j1YtutVRciQSH71t0o31VMdfGn4Mw+97nqwBcAi91KBHamEkMTmd2V0VkFDWHB eiKFROwwWFaU0tJTEuoYtGcYxzAEoHLitMQNFmDv6hFlKyM8Rd573bjCW/++T7Ib oaGjJbnE+HM/n86iF3gnsi3Ec0SZuyuaRgLUWViPmnzUgstPlNjCNmCVKVu2yxpc a6ttNt/xCv5UBSHSDGVS/+kwFwPliXoyiWOYwWq0aVaHY0vbrXzJls5CdmvLC6G2 ZURWRUAySV+DSC/U0jkLpA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1732211671; x=1732298071; bh=t vbfdd3/mch0/vh9IREtEsq17/DUPMcDkTWF9RDb5e8=; b=uyl2IN0qD3rwgk2K0 KOLjz54ZeYtcgGDcT/+InAicbe+GVklEURADHD2Km/uODSGt8/DR0tPPrzDYZ742 0weTVcSCheuH+6sIi7h62WdYzIyAauBsVQQM2pUuXO+PrcIHMgg/5q8v5lUshqvT N1+iL8gc2WffEYLSPlYtLVhyGyAS8qQk0bJBcqdr5/g0ttWMnvD4bZ6pL7vhMQKK JSAjoO7RkORjD/Dwsj63Ci2l+AiaPsCNPEgLlTt3lZ0fBUq3h72K4RsbF5GDqiJf GlWSMrfl9f1s3cu3MX6vq/jPmsM2rbWZ48S9FJn/4JRey+rHGm9+GPX59NyOpRpO wxEPw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfeeigddutdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeen ucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrse grkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeelgeevkeekkeeuiefgtdev ieeluefhfedufeetkeejffekjeeujeehgeehgeektdenucffohhmrghinhepphhoshhtgh hrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspg hrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepshgsohhulhgr nhhgvghrvdelsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrh grlhesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Nov 2024 12:54:30 -0500 (EST) Message-ID: <6a157286-5948-48ac-bc50-7bb4e65ee5e5@aklaver.com> Date: Thu, 21 Nov 2024 09:54:30 -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 , pgsql-general@postgresql.org References: 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/21/24 09:29, Steeve Boulanger wrote: > Hello, > > I have noticed recently that our databases (ie most but not all) have > their stats reset on daily basis: > > select count(case when stats_reset > (now() - interval '1 day') then 1 > else null end) db_reset_cnt, count(*) db_total_cnt from pg_stat_database; >  db_reset_cnt | db_total_cnt > --------------+-------------- >            77 |          157 > > Furthermore, the archiver stats also get reset: > > select stats_reset from pg_stat_archiver; >           stats_reset > ------------------------------- >  2024-11-21 13:52:35.864855+00 > > Some facts: > - PostgreSQL v13.16 on Linux Ubuntu 20.04 > - There's no evidence in the logs that any pg_stat_reset* functions have > been executed >             name            | setting > ----------------------------+--------- >  log_min_duration_statement | 0 >  log_statement              | all > - we don't have any user procs with a pg_stat_reset call > - the timestamps of the reset across databases are sometimes close to > each other, but not always > Anyone has any insight on what could be doing this daily stats reset, or > perhaps how to find the root cause? https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-STATS-SETUP "Cumulative statistics are collected in shared memory. Every PostgreSQL process collects statistics locally, then updates the shared data at appropriate intervals. When a server, including a physical replica, shuts down cleanly, a permanent copy of the statistics data is stored in the pg_stat subdirectory, so that statistics can be retained across server restarts. In contrast, when starting from an unclean shutdown (e.g., after an immediate shutdown, a server crash, starting from a base backup, and point-in-time recovery), all statistics counters are reset." > > Regards, > Steeve > -- Adrian Klaver adrian.klaver@aklaver.com