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 1mIybc-0006Dp-7G for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Aug 2021 19:30:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mIyb5-0002ml-6u for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Aug 2021 19:30:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mIyb4-0002mc-Rz for pgsql-hackers@lists.postgresql.org; Wed, 25 Aug 2021 19:30:02 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mIyax-0002wH-Bx for pgsql-hackers@lists.postgresql.org; Wed, 25 Aug 2021 19:30:02 +0000 Received: by mail-io1-xd2d.google.com with SMTP id b200so409500iof.13 for ; Wed, 25 Aug 2021 12:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=CxOSqLhH7iwgu5Ya0BtMvDp95LpoFRQcUqrNUoTfTec=; b=oXelCU0Tgn0m56HpNJW5KLxfIkdzUFD5aAvSAp6r6u7IZ+WZZV8GU7MDD4VCK+6KXa A2vHx0oyo2L/9i8XfEEbXPQJQlKnPU0m8K0rVrd7OZ/nYUp6E2RWdDxf8n7Zsg/uiO6X Gb36TdPHjNRXNnM9PNHyBV7j42UCWmpaf2RDJfKjTh3F4V/p4tkN89nNPQ80haLetgZc fFAFWgHzW2tWEY4XJ3zKH7u3Y6Eo/7+lwV6FqYPWLebRABUAxpvBOroxmjPvS01JA67O nxvEMnH2ubx3sLNRKocbnonAJy/oztJTnbvYaPviunjUYTWRVieOxIgw3ZvgON6ca+XO HITQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=CxOSqLhH7iwgu5Ya0BtMvDp95LpoFRQcUqrNUoTfTec=; b=GfOf0E2794dnnE8Go4hZmiPEfNCee5LC6GEJtn02OCpM/W2Wl9+xgz0lbTOaionheh TfUvsj8Afa/hfOzr7BcXUwmrpbWa1inifKKC1o5AJx3FxtZxqcI8/+67KxJ6kucprpNF gW03pJGkSqRBbihjrfZZKj0FbmrI28UTHARHhPIy5LS/wDg2Atg9DDn+9gqCts/cD9H+ 2DIa4gUJImZsLU+X57Sy9vDa+Rsu6MNFZ7XXZyPJQyLJdzgBrR1XmGxN6j1wr1uqknE9 SZ6rptCpXQ/vEharNIibac/1eke4uslgLNx3IVuRSZtwRDGQmCNEku+iX9VlTsn8L+xO DmLw== X-Gm-Message-State: AOAM533X9iS+AR9dDUeRMxfcrsS2dbni+Cl7A3DQQU6Qb7NF5brMB/2I wNfeTeLJz5Px4EbHbC54jMsaEg== X-Google-Smtp-Source: ABdhPJyba0fgQiECPNXhn9SzefPh8Z+ZhrCek9OtBOXItMV12AKICQmE5xEgFcR13l8bLRjwAm5acQ== X-Received: by 2002:a6b:8b54:: with SMTP id n81mr58967iod.5.1629919792864; Wed, 25 Aug 2021 12:29:52 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x10sm481267ila.4.2021.08.25.12.29.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Aug 2021 12:29:52 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 3CFF1800837; Wed, 25 Aug 2021 14:29:51 -0500 (CDT) Date: Wed, 25 Aug 2021 14:29:51 -0500 From: Justin Pryzby To: =?iso-8859-1?Q?=C1lvaro?= Herrera Cc: Andres Freund , Kyotaro HORIGUCHI , yuzuko , Tomas Vondra , David Steele , Kyotaro Horiguchi , Daniel Gustafsson , Amit Langote , Masahiko Sawada , Laurenz Albe , pgsql-hackers@lists.postgresql.org, Greg Stark , Michael Paquier , Peter Geoghegan , Andrew Dunstan Subject: Re: Autovacuum on partitioned table (autoanalyze) Message-ID: <20210825192951.GD10479@telsasoft.com> References: <202108161546.3zuouk76skr4@alvherre.pgsql> <202108162142.crk2myigb2ad@alvherre.pgsql> <20210816222810.GE10479@telsasoft.com> <20210817113018.GG10479@telsasoft.com> <20210820125513.GQ10479@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210820125513.GQ10479@telsasoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Aug 20, 2021 at 07:55:13AM -0500, Justin Pryzby wrote: > On Tue, Aug 17, 2021 at 06:30:18AM -0500, Justin Pryzby wrote: > > On Mon, Aug 16, 2021 at 05:28:10PM -0500, Justin Pryzby wrote: > > > On Mon, Aug 16, 2021 at 05:42:48PM -0400, Álvaro Herrera wrote: > > > > On 2021-Aug-16, Álvaro Herrera wrote: > > > > > > > > > Here's the reversal patch for the 14 branch. (It applies cleanly to > > > > > master, but the unused member of PgStat_StatTabEntry needs to be > > > > > removed and catversion bumped). > > > > > > > > I have pushed this to both branches. (I did not remove the item from > > > > the release notes in the 14 branch.) > > > > > > | I retained the addition of relkind 'p' to tables included by > > > | pg_stat_user_tables, because reverting that would require a catversion > > > | bump. > > > > > > Right now, on v15dev, it shows 0, which is misleading. > > > Shouldn't it be null ? > > > > > > analyze_count | 0 > > > > > > Note that having analyze_count and last_analyze would be an an independently > > > useful change. Since parent tables aren't analyzed automatically, I have a > > > script to periodically process them if they weren't processed recently. Right > > > now, for partitioned tables, the best I could find is to check its partitions: > > > | MIN(last_analyzed) FROM pg_stat_all_tables psat JOIN pg_inherits i ON psat.relid=i.inhrelid > > > > > > In 20200418050815.GE26953@telsasoft.com I wrote: > > > |This patch includes partitioned tables in pg_stat_*_tables, which is great; I > > > |complained awhile ago that they were missing [0]. It might be useful if that > > > |part was split out into a separate 0001 patch (?). > > > | [0] https://www.postgresql.org/message-id/20180601221428.GU5164%40telsasoft.com > > > > I suggest the attached (which partially reverts the revert), to allow showing > > correct data for analyze_count and last_analyzed. > > Álvaro, would you comment on this ? > > To me this could be an open item, but someone else should make that > determination. I added an opened item until this is discussed. | pg_stats includes partitioned tables, but always shows analyze_count=0 | Owner: Alvaro Herrera Possible solutions, in decreasing order of my own preference: - partially revert the revert, as proposed, to have "analyze_count" and "last_analyzed" work properly for partitioned tables. This doesn't suffer from any of the problems that led to the revert, does it ? - Update the .c code to return analyze_count=NULL for partitioned tables. - Update the catalog definition to exclude partitioned tables, again. Requires a catalog bumped. - Document that analyze_count=NULL for partitioned tables. It seems to just document a misbehavior. -- Justin