Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibhrK-0003KC-5K for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Dec 2019 09:19:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ibhrI-0007Dm-By for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Dec 2019 09:19:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ibhrH-0007Df-Vf for pgsql-hackers@lists.postgresql.org; Mon, 02 Dec 2019 09:19:08 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ibhrE-0000xe-3r for pgsql-hackers@lists.postgresql.org; Mon, 02 Dec 2019 09:19:06 +0000 Received: by mail-wr1-x442.google.com with SMTP id a15so43211056wrf.9 for ; Mon, 02 Dec 2019 01:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=yT/xje8l469PZS7ebivVmlMVwbWhZNiPy957keG5ots=; b=ZpyuswTSyeE/4e8fZYfpjg7zjbKl030MfRw76LMCReFaNIjZajXkYm00WyM44h0GxA /6Y8Y7OdLP/mtLqvg61cckOAJgBvTLGjdnIKlNY/fFHDy2DbhQdUSAQvWFh1pgA3wQqW UL3Dh8Y64kzq0toIJ7uKmaggnKPZVqP7aylTkLPFslBAJFvc0a5a5WWZwYMVQDr6iixF LTi1WXBJT+fcqhYeulRxx59laKulx8qAJKIerZkiLthHy4D6IBV2Tn2v/ip8iowoYmd1 lslwHahU5xo5bCTz5kwgPuWbyJ8w365F214SmXQyUMBYW9F4o1aaOZhcRvKVXd0NX0Fy Cc8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=yT/xje8l469PZS7ebivVmlMVwbWhZNiPy957keG5ots=; b=Pbet8zhdyL04Qwa+vdhIF0YI/DmNn/hXHVIvM0NZjSdXqlMR0K4t0QCI4sfDqyyKKT BCOyeCtoC+AqEVC3FNJGvRy4JThEI9W3SFIdEfSjXKoXMbGrovIalllVD7dfoxiSITau hOMSZWauIw6Z+FWWWQF7kQ4KQ+FdH32+8RNM7LrbmyI2E9/z/DFtMG0kVr5OR2t9Fvwx zv1L+JsFy+gerHs3/0Bcyy7OGjb7MPvLG51vaZDtkrmtRWMKfJRegR+3t/M/u3CCjWx4 yBeCty1vL/V+fRsxrDuZb9xoKk1u7fvX02/oEh5sg3N358SZ9nRrHjZNwvX/Q/4Pi6d/ FHlg== X-Gm-Message-State: APjAAAULXzqvcloqQNUKAzYVpeW0/FXvQbuqZnLEfhIuxjHRgg/D/EXR Ib9lybPtHWRoH4l+bQyF2MRHOg== X-Google-Smtp-Source: APXvYqybAYX8umpjsOi9KiZt1etoyG02oiIqYrVuxGhVTX4p3HAslFlk9Tk2MaFz5wos10soFRCDpw== X-Received: by 2002:adf:f64b:: with SMTP id x11mr49443710wrp.355.1575278342335; Mon, 02 Dec 2019 01:19:02 -0800 (PST) Received: from localhost.localdomain (217-149-169-193.nat.highway.telekom.at. [217.149.169.193]) by smtp.gmail.com with ESMTPSA id j12sm25851246wrw.54.2019.12.02.01.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 01:19:01 -0800 (PST) Message-ID: Subject: Re: Autovacuum on partitioned table From: Laurenz Albe To: yuzuko , PostgreSQL Hackers Cc: Greg Stark Date: Mon, 02 Dec 2019 10:19:01 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 2019-12-02 at 18:02 +0900, yuzuko wrote: > Greg reported in [1] before, autovacuum ignores partitioned tables. > That is, even if individual partitions’ statistics are updated, its parent's > statistics are not updated. This is TODO for declarative partitioning. > As Amit mentioned in [2], a way to make parent's statistics from > partitions' statistics without scanning the partitions would be nice, > but it will need a lot of modifications. So I tried to fix that using the > current analyze method. > > The summary of the attached patch is as follows: > * If the relation is a partitioned table, check its children if they need > vacuum or analyze. Children need to do that are added to > a table list for autovacuuum. At least one child is added to the list, > the partitioned table is also added to the list. Then, autovacuum > runs on all the tables in the list. That means that all partitions are vacuumed if only one of them needs it, right? This will result in way more vacuuming than necessary. Wouldn't it be an option to update the partitioned table's statistics whenever one of the partitions is vacuumed? Yours, Laurenz Albe