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 1jSLYl-0005lN-2X for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Apr 2020 14:13:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jSLYh-00011c-Vm for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Apr 2020 14:13:31 +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 1jSLYh-00011V-JR for pgsql-hackers@lists.postgresql.org; Sat, 25 Apr 2020 14:13:31 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jSLYa-0002dS-Gf for pgsql-hackers@lists.postgresql.org; Sat, 25 Apr 2020 14:13:30 +0000 Received: by mail-qt1-x841.google.com with SMTP id i68so10416944qtb.5 for ; Sat, 25 Apr 2020 07:13:24 -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:in-reply-to:user-agent; bh=OAvHPXCxEFP6v7qcS2mWIkqRX0pRyfJb4KGSebihKtg=; b=wVdgvIrVW/0zcJzwrCTJUpRcjGZdoYfQF4qL85sOKa5XE9fue51qOUpM82f5pfhy4J Rt+jSS2UTQTWoPEdW16c8noG/3JB5YIqDnaVPqeuNE1d/fdLf+af2FFNsKgKScymVJ7T dVI3FHP5u+U9AumzJjm7C+f3deg77wuguk2jbHITkCS3p1RY4R4K6K8ghnsd812Dkhdo Xth4v5po0/yVmV7cFmU0lGo4zM/8LWkf6tG+drSAiSKpxewj0Xh/l+qpn0cQJSRW1/KY cAZ+UmKwcxfq7iMyo1Xl8th7QCOTQP5lK1qQAucRSM91U2VIPgkYvwe5wM5lRDANqCa5 LaKA== 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:in-reply-to:user-agent; bh=OAvHPXCxEFP6v7qcS2mWIkqRX0pRyfJb4KGSebihKtg=; b=opR/1L1a8SZ4Y9S+2hLtsQjdcicRxop6HTEc5Z12SViYreZalT5Zbm8zJPA0P1Qp5q i15alIbKjPUhlEbWoGYpSe22yiGlDV0mD0mRhBD9/4Ys24+Vfd7a/vv+SMphzer4DDhp niNe+4jvnfdovUda710aWIHbS58DcR4WyiC1bFhgY7zw2UJ8+xplDRxOmyMBN5N6NcEc +TDZx5aQq+Mf2OjOfn/MaRAuuec4J14X6byLGGd4q1bSirUOP2nYqxbtYRtPHxMRIPa2 XP85NPzfqBe2yiaVgIOVOAybNRVVKPqVubju/3WssbGQnMxTWbUn9iaUaAJnKZ7lZUv7 dfwA== X-Gm-Message-State: AGi0PuZoDre6iAcqrpTUaLqur1oLWgFYEKtDRfH2CbNjpkNO+vETNY37 EqKkRH7Tboqtv91JFWDDOAoF8Q== X-Google-Smtp-Source: APiQypK+Q5CZaPgBIsJEO1MAAxFlrBen9VfMibEmN6xy8v4pfZmjXYAK1mCBPnDnGeB38RrYUxyrGA== X-Received: by 2002:ac8:4e88:: with SMTP id 8mr14672168qtp.82.1587824003491; Sat, 25 Apr 2020 07:13:23 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id o43sm6073755qtf.46.2020.04.25.07.13.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Apr 2020 07:13:22 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id DA3E6800929; Sat, 25 Apr 2020 09:13:20 -0500 (CDT) Date: Sat, 25 Apr 2020 09:13:20 -0500 From: Justin Pryzby To: yuzuko Cc: Amit Langote , Alvaro Herrera , Masahiko Sawada , Laurenz Albe , pgsql-hackers@lists.postgresql.org, Greg Stark Subject: Re: Autovacuum on partitioned table (autoanalyze) Message-ID: <20200425141320.GR28974@telsasoft.com> References: <20200228022545.GA19686@alvherre.pgsql> <20200318163039.GL26184@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200318163039.GL26184@telsasoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Mar 18, 2020 at 11:30:39AM -0500, Justin Pryzby wrote: > In the past, I think there's was talk that maybe someone would invent a clever > way to dynamically combine all the partitions' statistics, so analyzing the > parent wasn't needed. [...] I happened across the thread I was referring to: https://www.postgresql.org/message-id/7363.1426537103@sss.pgh.pa.us I'm not opposed to doing things the currently-proposed way (trigger analyze of partitioned tables based on updates, same as nonpartitioned tables), but we should think if it's worth doing something totally different, like what Tom proposed. Robert had concerns that it would increase planning time. I imagine that argument is even stronger now, since PG12 has *less* planning time for large heirarchies (428b260f8) and advertizes support for "thousands" of partitions. Tom said: > we would automatically get statistics that account for > partitions being eliminated by constraint exclusion, because only the > non-eliminated partitions are present in the appendrel. And second, That's a pretty strong benefit. I don't know if there's a good way to support both(either) ways of doing things. Like maybe a reloption that allows triggering autovacuum on partitioned tables, but if no statistics exist on a partitioned table, then the planner would dynamically determine the selectivity by decending into child statistics (Tom's way). I think the usual way this would play out is that someone with a small partition heirarchies would eventually complain about high planning time and then we'd suggest implementing a manual ANALYZE job. I'm not sure it's good to support two ways anyway, since 1) I think that gives different (better) statistics Tom's way (due to excluding stats of excluded partitions); 2) there's not a good way to put an ANALYZE job in place and then get rid of parent stats (have to DELETE FROM pg_statistic WHERE starelid='...'::regclass; 3) if someone implements an ANALYZE job, but they disable it or it stops working then they have outdated stats forever; -- Justin