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 1s9RpX-002Mxh-AQ for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2024 15:55:13 +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 1s9RpW-00AxrD-PN for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2024 15:55:10 +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 1s9RpV-00Axr4-Qo for pgsql-general@lists.postgresql.org; Tue, 21 May 2024 15:55:10 +0000 Received: from fhigh1-smtp.messagingengine.com ([103.168.172.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9RpS-001JQu-HW for pgsql-general@lists.postgresql.org; Tue, 21 May 2024 15:55:08 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id C8E4211400D9; Tue, 21 May 2024 11:55:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 21 May 2024 11:55:04 -0400 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=1716306904; x=1716393304; bh=tUte96a97a1X8Zz4KInHH0T1EQwbzgZ34gO4YqSWfwk=; b= QK0npsbl3O7Verewz2xDC/qZ1ihiWOmx0Fq0ACGcqjq5gsRw9wLjzRRWRfB+RLHt 6EZIF/z+uUEpH7hnNIfA4FLudfbNFKpcgZqpa+NdCW89fRs4ZjG2/NpJfXkBFjOr bCRWRKIB8YMZDtdB0yLuI5xJmcHcsObE/XUFA5Zw3rjeU2R8URyjmKRNE+GO5WN7 8pKjlPRLLKhvVnKgUmJ9VHg39I489gBVEXKGRu2zs+plVEEK4zPfUVlpppyqNJWQ P+Iqqitm9mz3f844MZrcKiqd1fYpUc6KlejiVddC9vw1IyUvXUjnCmOATpuwudyf MYM7tvLys+SlhR6fgAsB5Q== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716306904; x= 1716393304; bh=tUte96a97a1X8Zz4KInHH0T1EQwbzgZ34gO4YqSWfwk=; b=l 0YZGh8rIO594Ww687VBdgoxmEQMFEc4rWqfRszWdtE0hy1khpTeJDSNME/GxunBX 6QkrRmYmB9PRuqhYPIHwvIFxaIew/tn45QFbySuO2rgkWfwIhd6kbTyuGh2yvA+7 Y+zYXlNaZ+ctf2/rPRs2inRv0nBxRVbg/hnrHbLPN0CWsPE3BzToiiRnSiKaCdWm rKMrDB6Kml49dXViJkWGMuLZ08mpLlvHZzAenNFYJzlJrzxF0CipDo/K9OkCnJKT dcRwoNEWhziG2RIV0sp2sFiNY8qdLEyl44S/s5a/ri/ydBGCo8STYGrqkiNYmsQ6 7Fi5ohv8WRTeSnwtSBgwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeivddgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeeivdfhieehheegueeileejieettdejhedugeefleek vdelkeehtdfgiefffeekudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 May 2024 11:55:03 -0400 (EDT) Message-ID: <501b644f-ecb1-44b5-9822-bb322c801cd4@aklaver.com> Date: Tue, 21 May 2024 08:55:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Restore of a reference database kills the auto analyze processing. To: HORDER Philip , "pgsql-general@lists.postgresql.org" References: <7343f73e08294d4b997494f7b072ced6@uk.thalesgroup.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <7343f73e08294d4b997494f7b072ced6@uk.thalesgroup.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/21/24 06:00, HORDER Philip wrote: > Classified as: {OPEN} > >> Assuming clean shutdowns the statistics will survive restarts. They would be wiped when you drop a database and start over, have an unclean shutdown or you use one of the reset functions... > > Yes, stats are permanent, but are not being updated. > We don't use any of the pg_stat_reset functions. > > ------------------------------------- > I've left the system alone over the weekend. > Here's the timeline: > > 14th May: > Postgres working ok, 1767 log entries for "automatic analyze", mostly in database postgres. > 03:30 Jenkins deployed an update, resulting in reload of lfm database. This is where I am getting confused. In your original post you had: To apply an update, we: stop the applications that use LFM, set the user (LFU) to NOLOGIN kill any left-over connections: select pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'lfm' and usename = 'lfu'; drop the existing reference database using the dropDb utility. reload the new file using pg_restore and the postgres super user. set the user (LFU) to LOGIN In other words DROP DATABASE then CREATE DATABASE and reload the schema objects and associated data. Yet your int stats output.txt file has things like the following: -[ RECORD 3 ]-------+-------------------------------------------------- relid | 923130055 schemaname | a relname | cr_pt_e_202405020000_202405030000 seq_scan | 1264 seq_tup_read | 8800722491 idx_scan | 4601405 idx_tup_fetch | 4415621 n_tup_ins | 3851400 n_tup_upd | 15790 n_tup_del | 0 n_tup_hot_upd | 0 n_live_tup | 7166325 n_dead_tup | 0 n_mod_since_analyze | 0 n_ins_since_vacuum | 0 last_vacuum | last_autovacuum | 2024-05-03 09:03:44.810654+00 last_analyze | 2024-05-09 08:44:37.725674+00 last_autoanalyze | 2024-05-03 09:03:58.838664+00 vacuum_count | 0 autovacuum_count | 1 analyze_count | 1 autoanalyze_count | 1 I am having a hard time figuring out how both of the above can be true. Dropping and recreating the database would wipe out the statistics. > Summary: since the reload of lfm database on 15th May, the only "automatic analyze" events logged have been for the lfm database, at the point of reload. > No other stats analyze seems to have taken place, on any database on the server since that point, even partitions with over a million rows. The above is confusing also. In your original post you only referred to the postgres and lfm databases. What other databases are you referring to? As to partitions are you referring to partitions of tables in the lfm database or something else? > Apart from that, Postgres appears to be working normally. > > I'm sure that another restart of Postgres will restore the auto analyze, until the next pg_restore of lfm. > So what's going on? How is it that we're breaking this important function that we shouldn't be able to have any effect on? > > Thanks for looking, > Phil Horder > Database Mechanic > > Thales > Land & Air Systems > -- Adrian Klaver adrian.klaver@aklaver.com