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 1lURfj-0004wS-K6 for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 10:13:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lURfi-00011I-I9 for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 10:13:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lURfi-00011B-Aj for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 10:13:58 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lURff-0003a1-0W for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 10:13:57 +0000 Received: by mail-ej1-x636.google.com with SMTP id s21so2054703eju.8 for ; Thu, 08 Apr 2021 03:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=YNZiuqRFenfgug3byjIZcl/0CeoIWu5AF3ST3HSDh8Q=; b=H1Bw/XKm4497rtYNuWZQ2+OdHg0JzZmzmd0I8cwx6jL/bIQz4dZclNmJ2Uj0khCCxC lhKp77+hPQPPvEL9huPlQI9t072GFYWKnEoTc1+Z0Rx2MQVDiEFwykPU7PPr9jEyDfKT cke9MqVh3yh/7jkrKpSetinUepzmHjnq/juloeeUz8vBuY6KX1TA3RxFAwPEcWWAiWSt 2F9emfXZM1lU+JEAPYBeRwtMzd7DlwgQQkYtyv3yw1siW40+0NuBwJWPhUU0voe9cu+7 1pIMwvvzD4tXt0kmxNgZzqvAAOqStMY7SGyqhE2JJxw6HScy3P1MjzN37NG52Z1grcFT Kasg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YNZiuqRFenfgug3byjIZcl/0CeoIWu5AF3ST3HSDh8Q=; b=TR2xeQGgXXoQswa4BYrlpXCC0KssbdVTOPlA6fiyX84Ds2QgOLy27Z1Rwg2FjLITGY RXhhExXSQDmB847TsN474xBQNtNKDKaV3pci+LvxKbSdTk1IfM5s9udiuRGWy1mqz4P2 ejfPSyFLSFg8WUhkEn51YoyaoAnnKfqijz7dZlGYSbab2WVMnloLz5PT3YiXGPAS68oD omr4SZfF6aHy4bXLTvMIqQ3VViAetmanQQwDmZjaBuwLIHWGnZGbafaAFhvtrOV51e0H T3C+qa6OxongZufb9H6HM+JUjLx0lC/XZNbFKenQIgx1e4mw+ouhYyMi/a1n4TpTlMSF MqLg== X-Gm-Message-State: AOAM53372Dph5hdWiF7DfUrISuhQr7FQNyTdJlAwe33q/vLO9PfflGsp VKARS68y1ywX4ZVpUakf8cI8hEtnthMDRl4g5W4rzBflv27yeTnl6RoUo69ieFDqa4U+VGAjenG kZGilgiSS+RgSVDjQ7hTBKrbkXuvEnMsIsPCS2sWKfJXd9yKcOulHkeaLKMikzp4GnofbTKQedk uKWMmXxIP8qNgbHUba+yXRPiqkDwm9Iw3QZkVhymU4r9TbZk+3QqDm X-Google-Smtp-Source: ABdhPJw39ve17GMIYPI+a5iZrugaPIAXyX48PVv2nZZXcI87Q3t0zSV/pdUA0TMjLD9So4ywv0wyMQ== X-Received: by 2002:a17:906:9598:: with SMTP id r24mr6994556ejx.397.1617876833410; Thu, 08 Apr 2021 03:13:53 -0700 (PDT) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id rk11sm7638802ejb.60.2021.04.08.03.13.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Apr 2021 03:13:52 -0700 (PDT) Subject: Re: Autovacuum on partitioned table (autoanalyze) To: Alvaro Herrera , yuzuko Cc: David Steele , Kyotaro Horiguchi , Justin Pryzby , Daniel Gustafsson , Amit Langote , Masahiko Sawada , Laurenz Albe , PostgreSQL Hackers , Greg Stark References: <20210408032235.GA6842@alvherre.pgsql> From: Tomas Vondra Message-ID: <9ea106b4-22fc-fac5-2451-e876572284aa@enterprisedb.com> Date: Thu, 8 Apr 2021 12:13:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210408032235.GA6842@alvherre.pgsql> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/8/21 5:22 AM, Alvaro Herrera wrote: > OK, I bit the bullet and re-did the logic in the way I had proposed > earlier in the thread: do the propagation on the collector's side, by > sending only the list of ancestors: the collector can read the tuple > change count by itself, to add it to each ancestor. This seems less > wasteful. Attached is v16 which does it that way and seems to work > nicely under my testing. > > However, I just noticed there is a huge problem, which is that the new > code in relation_needs_vacanalyze() is doing find_all_inheritors(), and > we don't necessarily have a snapshot that lets us do that. While adding > a snapshot acquisition at that spot is a very easy fix, I hesitate to > fix it that way, because the whole idea there seems quite wasteful: we > have to look up, open and lock every single partition, on every single > autovacuum iteration through the database. That seems bad. I'm > inclined to think that a better idea may be to store reltuples for the > partitioned table in pg_class.reltuples, instead of having to add up the > reltuples of each partition. I haven't checked if this is likely to > break anything. > How would that value get updated, for the parent? > (Also, a minor buglet: if we do ANALYZE (col1), then ANALYZE (col2) a > partition, then we repeatedly propagate the counts to the parent table, > so we would cause the parent to be analyzed more times than it should. > Sounds like we should not send the ancestor list when a column list is > given to manual analyze. I haven't verified this, however.) > Are you sure? I haven't tried, but shouldn't this be prevented by only sending the delta between the current and last reported value? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company