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 1qY7Sq-000pon-5I for pgsql-general@arkaria.postgresql.org; Mon, 21 Aug 2023 16:09:12 +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 1qY7Sp-008DST-1H for pgsql-general@arkaria.postgresql.org; Mon, 21 Aug 2023 16:09: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 1qY7So-008DRu-KY for pgsql-general@lists.postgresql.org; Mon, 21 Aug 2023 16:09:10 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qY7Sl-000BG0-C9 for pgsql-general@postgresql.org; Mon, 21 Aug 2023 16:09:09 +0000 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2ba1e9b1fa9so54830851fa.3 for ; Mon, 21 Aug 2023 09:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692634146; x=1693238946; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=c2yF7PG9eqsTHb0dWcXyvTez4ZVA3BhgvQeH7UFjUUQ=; b=Hf7+cOiqTowxW9BxgZtFGaKtVGuiW5UDltWuIM9s+oJ+8W0TEkUUWTUBuyMmHzgssM 9wasUKH8OyNJx5RXBZMTtEe8ljlLL7uIr7e+1UdmXdpDA8Ysz6T/V6y6DdZ17KoZXPl+ nfLl/YiVS9jw1KUmR9yH0PpqjD6PR4NHdoXzX+rQkqJojOWdM69saFCiKJHz8dgVmotn cerckdmBIBsEwEy5bVE0INpo4gaIsFZVsnflc9pmXcfUYsC31VDFN7sguGXptVa3+8kP KxF3Ist1Ee+x/QSWMZnAgXvEfjun+YkHejV2prl9KoNaDljCc6LG2gpr7TKDG6r9Bfbv 57mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692634146; x=1693238946; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c2yF7PG9eqsTHb0dWcXyvTez4ZVA3BhgvQeH7UFjUUQ=; b=gXSCFIPXTHl6d+lxAjqhSpiHGr7kXV9FYYIjzOEkN55hBwWqywtXtjX4tYn6J9qU7n njXBPWYSXmKrs93nkpz9P3Kr8DlDFLPC7mXqFgMNbdL2Y8g1Nim0SUhbdVYtVavcQxyN tm82uyNQemOkzizxzGcTyFt8xgYkbjysqd/Hz5b/1UdccMLyiQsS9dQDM3QZuYGC00JG i3DIDqcM7GI3V0UkYUEVoT13Odb8bYVt+Kpf8v0rePLnwa9vb5PfOleQyhhQbKUzVMUR FkVWdF7LggkdplvqnRue+Q8v7iWpSGrbPAlv6aLrkbRssbpeH6Af2+pIEavilM0avEyh R2WA== X-Gm-Message-State: AOJu0Yycq6Uq1Hfk0U/+gJlORmYge/zS2Zv/DouF7evdJ7+nXBbOIFBs EnZivPvWhzAGqkoCfpv1T3+w7x32eF8= X-Google-Smtp-Source: AGHT+IFpg3vATxCUt+kvgEaM2UWNOeDctYnDkKMlBeEuOFBx2vApHnVppMKmjvCU8NaVFiZXlzIrZg== X-Received: by 2002:a2e:9592:0:b0:2b7:14d4:ce6d with SMTP id w18-20020a2e9592000000b002b714d4ce6dmr5609051ljh.48.1692634145401; Mon, 21 Aug 2023 09:09:05 -0700 (PDT) Received: from [192.168.0.254] ([5.134.59.114]) by smtp.gmail.com with ESMTPSA id s19-20020a2e81d3000000b002b6b7a98c4bsm2386564ljg.77.2023.08.21.09.09.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Aug 2023 09:09:04 -0700 (PDT) Message-ID: <918f94be-41b9-e684-7679-b6bd819f693c@gmail.com> Date: Mon, 21 Aug 2023 20:09:03 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: Why doesn't autovacuum/analyze run in due time after calling pg_stat_reset? To: Adrian Klaver , pgsql-general General References: <69eacc0a-7e9b-4a35-278b-110b93d72882@mail.ru> <18167fbd-815f-9b43-7016-5e5bbb8fb255@gmail.com> <9440ab9c-4ee1-7668-5476-dc28e8086524@aklaver.com> Content-Language: en-US From: Rihad In-Reply-To: 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 8/21/23 20:00, Adrian Klaver wrote: > On 8/20/23 22:31, Rihad wrote: >> On 8/21/23 00:15, Adrian Klaver wrote: >>> On 8/20/23 12:10, Rihad wrote: >>>> On 8/20/23 20:22, Adrian Klaver wrote: >>>>> On 8/18/23 22:35, Rihad wrote: >>>>>> On 8/17/23 13:01, rihad wrote: >>>>>>> > >>> >>> Hard to say without seeing the actual settings in postgresql.conf >>> that match: >>> >>> https://www.postgresql.org/docs/current/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR >>> >>> >>> >>> Most importantly: >>> >>> autovacuum >>> >>> and >>> >>> track_counts >>> >>> https://www.postgresql.org/docs/current/runtime-config-statistics.html#GUC-TRACK-COUNTS >>> >>> >> >> They are both on and set as per default. Autovac/analyze continue >> running on some tables after pg_stat_reset. Just not on all of them, >> even thought they should judging by live/dead tuples calculation. >> >> >> foo=> show track_counts; >> track_counts >> -------------- >> on >> (1 row) >> >> foo=> show autovacuum; >> autovacuum >> ------------ >> on >> (1 row) > > How about the rest of the settings at?: > > https://www.postgresql.org/docs/current/runtime-config-autovacuum.html > > Have the storage parameters for the tables been changed per?: > > https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS > > > In psql you can do: > > \d+ > > The setting if changed will show up as Options: > > Also are there include directives in use per?: > > https://www.postgresql.org/docs/current/config-setting.html#CONFIG-INCLUDES > > > You can see by looking at the sourcefile field in pg_settings: > > https://www.postgresql.org/docs/current/view-pg-settings.html > Thanks for the detailed reply, no tables have custom settings. I need to make it clear once again that all autovac/analyze work as expected when n_live_tup matches reality, i.e. when analyze has been run on them since last reset. A way to fix this is to simply analyze the whole database. Before doing that, while n_live_tup starts from basically 0 and grows based on DB activity, these usual calculations of 10-20% table size for vacuum/analyze don't work. They don't trigger autovac for most tables, or do it much much later. >> >> >>>> >>>> >>>>> >>>>>> >>>>>> There are still many tables waiting for their turn, which is long >>>>>> due. >>>>>> >>>>>> Although there are some tables having only 60-70 (not 60-70K) >>>>>> n_live_tup that have had autovacuum run on them. Weird. >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>> >> >