Re: Autovacuum on partitioned table (autoanalyze)

2021-08-28 Thread Álvaro Herrera
On 2021-Aug-17, Justin Pryzby wrote: > I suggest the attached (which partially reverts the revert), to allow showing > correct data for analyze_count and last_analyzed. Yeah, that makes sense and my keeping of the pg_stat_all_tables entries seems pretty useless without this change. I have pushed

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-25 Thread Justin Pryzby
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 Her

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-20 Thread Justin Pryzby
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.

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-17 Thread Justin Pryzby
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_St

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-17 Thread Andres Freund
Hi, On 2021-08-16 13:13:55 -0400, Álvaro Herrera wrote: > Another possible problem is that before the revert, we accept > ALTER TABLE some_partitioned_table SET (autovacuum_enabled=on/off); > (also autovacuum_analyze_scale_factor and autovacuum_analyze_threshold) > but after the revert this is wil

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-17 Thread Andres Freund
Hi, On 2021-08-16 17:42:48 -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

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Justin Pryzby
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 pu

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Álvaro Herrera
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

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Álvaro Herrera
Another possible problem is that before the revert, we accept ALTER TABLE some_partitioned_table SET (autovacuum_enabled=on/off); (also autovacuum_analyze_scale_factor and autovacuum_analyze_threshold) but after the revert this is will throw a syntax error. What do people think we should do about

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Álvaro Herrera
On 2021-Aug-16, Tom Lane wrote: > =?utf-8?Q?=C3=81lvaro?= Herrera writes: > > 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 don't follow the connection to catvers

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > 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 don't follow the connection to catversion? I agree that we probably don't want to

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Álvaro Herrera
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). -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ Maybe there's lots of data loss but the records of

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-16 Thread Álvaro Herrera
On 2021-Aug-13, Álvaro Herrera wrote: > Some doc changes are pending, and some more commentary in parts of the > code, but I think this is much more sensible. I do lament the lack of > a syscache for pg_inherits. Thinking about this again, this one here is the killer problem, I think; this behav

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-13 Thread Álvaro Herrera
Here is a proposal for 14. This patch has four main changes: * The mod counts are only propagated to the topmost parent, not to each ancestor. This means that we'll only analyze the topmost partitioned table and not each intermediate partitioned table; seems a good compromise to avoid samplin

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-13 Thread Andres Freund
Hi, On 2021-08-11 18:33:07 -0400, Alvaro Herrera wrote: > After thinking about the described issues for a while, my proposal is to > completely revamp the way this feature works. See below. > > Now, the proposal seems awfully invasive, but it's *the* way I see to > avoid the pgstat traffic. For

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-11 Thread Alvaro Herrera
After thinking about the described issues for a while, my proposal is to completely revamp the way this feature works. See below. Now, the proposal seems awfully invasive, but it's *the* way I see to avoid the pgstat traffic. For pg14, maybe we can live with it, and just use the smaller patches

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-10 Thread Alvaro Herrera
On 2021-Aug-09, Alvaro Herrera wrote: > > 3) What is the goal of the autovac_refresh_stats() after the loop doing > >pgstat_report_anl_ancestors()? I think it'll be common that the stats > >collector hasn't even processed the incoming messages by that point, not > > to > >speak of act

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-10 Thread Alvaro Herrera
On 2021-Aug-10, Alvaro Herrera wrote: > I bring a radical proposal that may be sufficient to close this > particular hole. What if we made partition only affected their > top-level parents to become auto-analyzed, and not any intermediate > ancestors? Any intermediate partitioned partitions coul

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-10 Thread Alvaro Herrera
On 2021-Aug-09, Andres Freund wrote: > I don't agree. There's a difference between this happening after a manual > ANALYZE on partition roots, and this continuously happening in production > workloads due to auto-analyzes... Hmm. That's not completely untrue. I bring a radical proposal that may

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-09 Thread Andres Freund
Hi, On 2021-08-09 16:02:33 -0400, Alvaro Herrera wrote: > On 2021-Jul-27, Andres Freund wrote: > > > Isn't this going to create a *lot* of redundant sampling? Especially if you > > have any sort of nested partition tree. In the most absurd case a partition > > with n parents will get sampled n t

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-09 Thread Alvaro Herrera
Hello, On 2021-Jul-22, Andres Freund wrote: > 1) Somehow it seems like a violation to do stuff like >get_partition_ancestors() in pgstat.c. It's nothing I can't live with, but >it feels a bit off. Would likely not be too hard to address, e.g. by just >putting some of pgstat_report_anl

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-09 Thread Alvaro Herrera
Hi On 2021-Jul-27, Andres Freund wrote: > Isn't this going to create a *lot* of redundant sampling? Especially if you > have any sort of nested partition tree. In the most absurd case a partition > with n parents will get sampled n times, solely due to changes to itself. It seems to me that you

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-03 Thread Kyotaro Horiguchi
At Thu, 29 Jul 2021 18:03:55 -0700, Andres Freund wrote in > And if one instead inverts the order of pgstat_report_analyze() and > pgstat_report_anl_ancestors() one gets a slightly different problem: A manual > ANALYZE of the partition root results in the partition root having a non-zero > change

Re: Autovacuum on partitioned table (autoanalyze)

2021-08-03 Thread Andrew Dunstan
On 7/29/21 9:03 PM, Andres Freund wrote: > Hi, > > CCing RMT because I think we need to do something about this for v14. Thanks. We are now aware of it. [...] > I don't think the code as is is fit for v14. It looks like it was rewritten > with a new approach just before the freeze ([1]), an

Re: Autovacuum on partitioned table (autoanalyze)

2021-07-29 Thread Andres Freund
Hi, CCing RMT because I think we need to do something about this for v14. On 2021-07-27 19:23:42 -0700, Andres Freund wrote: > On 2021-07-22 13:54:58 -0700, Andres Freund wrote: > > On 2021-04-08 01:20:14 -0400, Alvaro Herrera wrote: > > > On 2021-Apr-07, Alvaro Herrera wrote: > > > > > > > OK, I

Re: Autovacuum on partitioned table (autoanalyze)

2021-07-27 Thread Andres Freund
Hi, On 2021-07-22 13:54:58 -0700, Andres Freund wrote: > On 2021-04-08 01:20:14 -0400, Alvaro Herrera wrote: > > On 2021-Apr-07, 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 si

Re: Autovacuum on partitioned table (autoanalyze)

2021-07-22 Thread Andres Freund
Hi, On 2021-04-08 01:20:14 -0400, Alvaro Herrera wrote: > On 2021-Apr-07, 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

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Tom Lane
Justin Pryzby writes: > On Thu, Apr 08, 2021 at 05:56:25PM -0400, Alvaro Herrera wrote: >> This new bit reads weird: >> >> +Most parameters are not supported on partitioned tables, with exceptions >> +noted below; you may specify them for individual leaf partitions. > "Except where noted

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Justin Pryzby
On Thu, Apr 08, 2021 at 05:56:25PM -0400, Alvaro Herrera wrote: > On 2021-Apr-08, Justin Pryzby wrote: > > > commit 0827e8af70f4653ba17ed773f123a60eadd9f9c9 > > |This also introduces necessary reloptions support for partitioned > > tables > > |(autovacuum_enabled, autovacuum_analyze_scale

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Alvaro Herrera
On 2021-Apr-08, Justin Pryzby wrote: > commit 0827e8af70f4653ba17ed773f123a60eadd9f9c9 > |This also introduces necessary reloptions support for partitioned tables > |(autovacuum_enabled, autovacuum_analyze_scale_factor, > |autovacuum_analyze_threshold). It's unclear how best to docume

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Justin Pryzby
On Thu, Apr 08, 2021 at 01:20:14AM -0400, Alvaro Herrera wrote: > On 2021-Apr-07, 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 co

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Alvaro Herrera
On 2021-Apr-08, Tomas Vondra wrote: > On 4/8/21 5:27 PM, Alvaro Herrera wrote: > > > Same as for any other relation: ANALYZE would set it, after it's done > > scanning the table. We would to make sure that nothing resets it to > > empty, though, and that it doesn't cause issues elsewhere. (The p

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Tomas Vondra
On 4/8/21 5:27 PM, Alvaro Herrera wrote: > On 2021-Apr-08, Tomas Vondra wrote: > >> On 4/8/21 5:22 AM, Alvaro Herrera wrote: > >>> 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 necess

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Alvaro Herrera
On 2021-Apr-08, Tomas Vondra wrote: > On 4/8/21 5:22 AM, Alvaro Herrera wrote: > > 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. Whi

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-08 Thread Tomas Vondra
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 eac

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-07 Thread Alvaro Herrera
On 2021-Apr-07, Alvaro Herrera wrote: > 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

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-07 Thread Alvaro Herrera
On 2021-Apr-07, 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 anc

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-07 Thread Alvaro Herrera
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

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-07 Thread yuzuko
Hi, I fixed the patch according to the following comments. Attach the latest patch. It is based on v14 patch Alvaro attached before. On Mon, Apr 5, 2021 at 4:08 AM Tomas Vondra wrote: > > On 4/3/21 9:42 PM, Alvaro Herrera wrote: > > Thanks for the quick rework. I like this design much better a

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-06 Thread Alvaro Herrera
On 2021-Apr-07, yuzuko wrote: > I'm working on fixing the patch according to the comments. > I'll send it as soon as I can. Thanks, I've been giving it a look too. > I've been thinking about traditional inheritance, I realized that we > need additional > handling to support them because unlike d

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-06 Thread yuzuko
Hello, Thank you for reviewing. I'm working on fixing the patch according to the comments. I'll send it as soon as I can. > On 2021-04-06 16:56:49 -0400, Alvaro Herrera wrote: > > I think there is a good reason to treat them the same: pgstat does not > > have a provision to keep stats both of the

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-06 Thread Andres Freund
Hi, On 2021-04-06 16:56:49 -0400, Alvaro Herrera wrote: > I think there is a good reason to treat them the same: pgstat does not > have a provision to keep stats both of the table with children, and the > table without children. It can only have one of those. For > partitioning that doesn't matt

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-06 Thread Alvaro Herrera
On 2021-Apr-04, Tomas Vondra wrote: > 1) I still don't understand why inheritance and declarative partitioning > are treated differently. Seems unnecessary nad surprising, but maybe > there's a good reason? I think there is a good reason to treat them the same: pgstat does not have a provision to

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-04 Thread Tomas Vondra
On 4/4/21 9:08 PM, Tomas Vondra wrote: > On 4/3/21 9:42 PM, Alvaro Herrera wrote: >> Thanks for the quick rework. I like this design much better and I think >> this is pretty close to committable. Here's a rebased copy with some >> small cleanups (most notably, avoid calling pgstat_propagate_c

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-04 Thread Alvaro Herrera
On 2021-Apr-04, Tomas Vondra wrote: > In fact, one of the first posts in this threads links to this: > > https://www.postgresql.org/message-id/4823.1262132964%40sss.pgh.pa.us > > i.e. Tom actually proposed doing something like this back in 2009, so > presumably he though it's desirable back then

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-04 Thread Tomas Vondra
On 4/4/21 10:05 PM, Alvaro Herrera wrote: > On 2021-Apr-04, Tomas Vondra wrote: > >> 1) I still don't understand why inheritance and declarative partitioning >> are treated differently. Seems unnecessary nad surprising, but maybe >> there's a good reason? > > I suppose the rationale is that fo

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-04 Thread Alvaro Herrera
On 2021-Apr-04, Tomas Vondra wrote: > 1) I still don't understand why inheritance and declarative partitioning > are treated differently. Seems unnecessary nad surprising, but maybe > there's a good reason? I suppose the rationale is that for inheritance we have always done it that way -- similar

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-04 Thread Tomas Vondra
On 4/3/21 9:42 PM, Alvaro Herrera wrote: > Thanks for the quick rework. I like this design much better and I think > this is pretty close to committable. Here's a rebased copy with some > small cleanups (most notably, avoid calling pgstat_propagate_changes > when the partition doesn't have a tabs

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-03 Thread Alvaro Herrera
Thanks for the quick rework. I like this design much better and I think this is pretty close to committable. Here's a rebased copy with some small cleanups (most notably, avoid calling pgstat_propagate_changes when the partition doesn't have a tabstat entry; also, free the lists that are allocate

Re: Autovacuum on partitioned table (autoanalyze)

2021-04-01 Thread yuzuko
Hi Tomas, Thank you for reviewing the patch. > Firstly, the patch propagates the changes_since_analyze values from > do_analyze_rel, i.e. from the worker after it analyzes the relation. > That may easily lead to cases with unnecessary analyzes - consider a > partitioned with 4 child relations: >

Re: Autovacuum on partitioned table (autoanalyze)

2021-03-30 Thread Tomas Vondra
On 3/30/21 4:09 AM, Tomas Vondra wrote: > Hi, > > ... > > We may need to "sync" the counts for individual relations in a couple > places (e.g. after the worker is done with the leaf, it should propagate > the remaining delta before resetting the values to 0). Maybe multi-level > partitioning n

Re: Autovacuum on partitioned table (autoanalyze)

2021-03-29 Thread Tomas Vondra
Hi, I took a look at this patch. It does not apply because of 5f8727f5a67, so a rebase is needed. But I want to talk about the general approach in general, so it does not matter. The thread is fairly long, both in terms of number of messages and time (started in 2019), so let me restate my unders

Re: Autovacuum on partitioned table (autoanalyze)

2021-03-11 Thread David Steele
On 12/14/20 8:46 PM, yuzuko wrote: On Thu, Dec 3, 2020 at 10:28 PM Alvaro Herrera wrote: Attach the new patch based on his patch. What do you think? Álvaro, Justin, Kyotaro, thoughts on this latest patch? Regards, -- -David da...@pgmasters.net

Re: Autovacuum on partitioned table (autoanalyze)

2020-12-14 Thread yuzuko
Hello Alvaro, On Thu, Dec 3, 2020 at 10:28 PM Alvaro Herrera wrote: > > Hello Yuzuko, > > On 2020-Dec-02, yuzuko wrote: > > > The problem Horiguchi-san mentioned is as follows: > > [explanation] > > Hmm, I see. So the problem is that if some ancestor is analyzed first, > then analyze of one of i

Re: Autovacuum on partitioned table (autoanalyze)

2020-12-03 Thread Alvaro Herrera
Hello Yuzuko, On 2020-Dec-02, yuzuko wrote: > The problem Horiguchi-san mentioned is as follows: > [explanation] Hmm, I see. So the problem is that if some ancestor is analyzed first, then analyze of one of its partition will cause a redundant analyze of the ancestor, because the number of tupl

Re: Autovacuum on partitioned table (autoanalyze)

2020-12-02 Thread yuzuko
Hello Alvaro, Thank you for your comments. > > > In second thought about the reason for the "toprel_oid". It is perhaps > > to avoid "wrongly" propagated values to ancestors after a manual > > ANALYZE on a partitioned table. But the same happens after an > > autoanalyze iteration if some of the

Re: Autovacuum on partitioned table (autoanalyze)

2020-11-30 Thread Alvaro Herrera
On 2020-Nov-10, Kyotaro Horiguchi wrote: > In second thought about the reason for the "toprel_oid". It is perhaps > to avoid "wrongly" propagated values to ancestors after a manual > ANALYZE on a partitioned table. But the same happens after an > autoanalyze iteration if some of the ancestors of

Re: Autovacuum on partitioned table (autoanalyze)

2020-11-30 Thread Alvaro Herrera
I looked at both Yuzuko Hosoya's patch and Kyotaro Horiguchi's, and think we're doing things in a quite complicated manner, which perhaps could be done more easily. Hosoya's patch has pgstat_report_analyze call pgstat_get_tab_entry() for the table being vacuumed, then obtains the list of ancestors

Re: Autovacuum on partitioned table (autoanalyze)

2020-11-10 Thread Kyotaro Horiguchi
At Thu, 5 Nov 2020 16:03:12 +0900, yuzuko wrote in > Hi Justin, > > Thank you for your comments. > I attached the latest patch(v11) to the previous email. > > > > > +* Get its all ancestors to propagate changes_since_analyze > > count. > > +* However, when ANALY

Re: Autovacuum on partitioned table (autoanalyze)

2020-11-04 Thread yuzuko
Hi Justin, Thank you for your comments. I attached the latest patch(v11) to the previous email. > > +* Get its all ancestors to propagate changes_since_analyze > count. > +* However, when ANALYZE inheritance tree, we get ancestors of > +* toprel_oi

Re: Autovacuum on partitioned table (autoanalyze)

2020-11-04 Thread yuzuko
Horiguchi-san, Thank you for your comments. On Fri, Oct 23, 2020 at 8:23 PM Kyotaro Horiguchi wrote: > > Thanks you for the new version. > > At Fri, 23 Oct 2020 15:12:51 +0900, yuzuko wrote in > > Hello, > > > > I reconsidered a way based on the v5 patch in line with > > Horiguchi-san's commen

Re: Autovacuum on partitioned table (autoanalyze)

2020-10-26 Thread Justin Pryzby
On Fri, Oct 23, 2020 at 03:12:51PM +0900, yuzuko wrote: > Hello, > > I reconsidered a way based on the v5 patch in line with > Horiguchi-san's comment. > > This approach is as follows: > - A partitioned table is checked whether it needs analyze like a plain > table in relation_needs_vacanalyze

Re: Autovacuum on partitioned table (autoanalyze)

2020-10-23 Thread Kyotaro Horiguchi
Thanks you for the new version. At Fri, 23 Oct 2020 15:12:51 +0900, yuzuko wrote in > Hello, > > I reconsidered a way based on the v5 patch in line with > Horiguchi-san's comment. > > This approach is as follows: > - A partitioned table is checked whether it needs analyze like a plain > tab

Re: Autovacuum on partitioned table (autoanalyze)

2020-10-22 Thread yuzuko
Hello, I reconsidered a way based on the v5 patch in line with Horiguchi-san's comment. This approach is as follows: - A partitioned table is checked whether it needs analyze like a plain table in relation_needs_vacanalyze(). To do this, we should store partitioned table's stats (changes_si

Re: Autovacuum on partitioned table (autoanalyze)

2020-09-17 Thread yuzuko
Horiguchi-san, Thank you for reviewing. On Tue, Sep 15, 2020 at 7:01 PM Kyotaro Horiguchi wrote: > > At Tue, 25 Aug 2020 14:28:20 +0200, Daniel Gustafsson wrote > in > > > I attach the latest patch that solves the above Werror. > > > Could you please check it again? > > > > This version now

Re: Autovacuum on partitioned table (autoanalyze)

2020-09-15 Thread Kyotaro Horiguchi
At Tue, 25 Aug 2020 14:28:20 +0200, Daniel Gustafsson wrote in > > I attach the latest patch that solves the above Werror. > > Could you please check it again? > > This version now pass the tests in the Travis pipeline as can be seen in the > link below, and is ready to be reviewed in the upcom

Re: Autovacuum on partitioned table (autoanalyze)

2020-08-25 Thread Daniel Gustafsson
> On 17 Aug 2020, at 08:11, yuzuko wrote: > > I'm sorry for the late reply. > >> This version seems to fail under Werror which is used in the Travis builds: >> >> autovacuum.c: In function ‘relation_needs_vacanalyze’: >> autovacuum.c:3117:59: error: ‘reltuples’ may be used uninitialized in this

Re: Autovacuum on partitioned table (autoanalyze)

2020-08-16 Thread yuzuko
I'm sorry for the late reply. > This version seems to fail under Werror which is used in the Travis builds: > > autovacuum.c: In function ‘relation_needs_vacanalyze’: > autovacuum.c:3117:59: error: ‘reltuples’ may be used uninitialized in this > function [-Werror=maybe-uninitialized] >anlthre

Re: Autovacuum on partitioned table (autoanalyze)

2020-08-01 Thread Daniel Gustafsson
> On 6 Jul 2020, at 12:35, yuzuko wrote: > >> On Wed, Jul 1, 2020 at 6:26 PM Daniel Gustafsson wrote: >> >>> On 21 Apr 2020, at 18:21, yuzuko wrote: >> >>> I'll update the patch soon. >> >> Do you have an updated version to submit? The previous patch no longer >> applies >> to HEAD, so I'm

Re: Autovacuum on partitioned table (autoanalyze)

2020-07-06 Thread yuzuko
> On Wed, Jul 1, 2020 at 6:26 PM Daniel Gustafsson wrote: > > > On 21 Apr 2020, at 18:21, yuzuko wrote: > > > I'll update the patch soon. > > Do you have an updated version to submit? The previous patch no longer > applies > to HEAD, so I'm marking this entry Waiting on Author in the meantime.

Re: Autovacuum on partitioned table (autoanalyze)

2020-07-01 Thread Daniel Gustafsson
> On 21 Apr 2020, at 18:21, yuzuko wrote: > I'll update the patch soon. Do you have an updated version to submit? The previous patch no longer applies to HEAD, so I'm marking this entry Waiting on Author in the meantime. cheers ./daniel

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-29 Thread Amit Langote
On Sat, Apr 25, 2020 at 11:13 PM Justin Pryzby wrote: > > 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 > > paren

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-25 Thread Justin Pryzby
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 t

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-21 Thread yuzuko
Hello, On Sat, Apr 18, 2020 at 2:08 PM Justin Pryzby wrote: > > On Fri, Apr 17, 2020 at 10:09:07PM +0900, Amit Langote wrote: > > On Thu, Apr 16, 2020 at 11:19 PM Justin Pryzby wrote: > > > On Thu, Apr 16, 2020 at 06:16:45PM +0900, yuzuko wrote: > > > I don't think that adequately allows what's

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-17 Thread Justin Pryzby
On Fri, Apr 17, 2020 at 10:09:07PM +0900, Amit Langote wrote: > On Thu, Apr 16, 2020 at 11:19 PM Justin Pryzby wrote: > > On Thu, Apr 16, 2020 at 06:16:45PM +0900, yuzuko wrote: > > I don't think that adequately allows what's needed. ...(paragraph with my typos elided)... > > For example, say a ne

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-17 Thread Amit Langote
On Thu, Apr 16, 2020 at 11:19 PM Justin Pryzby wrote: > On Thu, Apr 16, 2020 at 06:16:45PM +0900, yuzuko wrote: > > The latest patch lets users set different autovacuum configuration for > > each partitioned > > tables like this, > > create table p3(i int) partition by range(i) with > >(auto

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-16 Thread Justin Pryzby
On Thu, Apr 16, 2020 at 06:16:45PM +0900, yuzuko wrote: > > I think it ought to be possible to configure this feature such that an > > auto-analyze on any child partition would trigger analyze of the parent. I > > think that would be important for maintaining accurate stats of the > > partition >

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-16 Thread yuzuko
Hi Justin, Thank you for commens. On Tue, Apr 7, 2020 at 12:32 PM Justin Pryzby wrote: > > Not sure if you saw my earlier message ? > I'm sorry, I didn't notice for a while. > I think it ought to be possible to configure this feature such that an > auto-analyze on any child partition would trig

Re: Autovacuum on partitioned table (autoanalyze)

2020-04-06 Thread Justin Pryzby
Not sure if you saw my earlier message ? I think it ought to be possible to configure this feature such that an auto-analyze on any child partition would trigger analyze of the parent. I think that would be important for maintaining accurate stats of the partition key column for many cases involv

Re: Autovacuum on partitioned table

2020-04-06 Thread yuzuko
Hi Alvaro, Thank you for your comments. > I'm confused about some error messages in the regression test when a > column is mentioned twice, that changed from mentioning the table named > in the vacuum command, to mentioning the first partition. Is that > because you changed an lappend() to lcons(

Re: Autovacuum on partitioned table (autoanalyze)

2020-03-18 Thread Justin Pryzby
Regarding this patch: +* the ANALYZE message as it resets the partition's changes_since_analze => analyze +* If the relation is a partitioned table, we must add up children's childrens' The approach in general: I see an issue for timeseries data, where only the most recent parti

Re: Autovacuum on partitioned table

2020-03-17 Thread Alvaro Herrera
On 2020-Mar-18, yuzuko wrote: > > I think if we analyze partition tree in order from leaf partitions > > to root table, this problem can be fixed. > > What do you think about it? > > Attach the new patch fixes the above problem. Thanks for the new version. I'm confused about some error messages

Re: Autovacuum on partitioned table

2020-03-17 Thread yuzuko
Hello, > > > > + */ > > > > + if (IsAutoVacuumWorkerProcess() && > > > > + rel->rd_rel->relispartition && > > > > + !(rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)) > > > > > > I'm not sure I understand why we do this only on autovac. Why not all > > > analyze

Re: Autovacuum on partitioned table

2020-03-16 Thread yuzuko
Hello, Thank you for reviewing. > > > + */ > > > + if (IsAutoVacuumWorkerProcess() && > > > + rel->rd_rel->relispartition && > > > + !(rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)) > > > > I'm not sure I understand why we do this only on autovac. Why not all

Re: Autovacuum on partitioned table

2020-02-27 Thread Amit Langote
On Fri, Feb 28, 2020 at 11:25 AM Alvaro Herrera wrote: > > /* > > + * If the relation is a partitioned table, we must add up children's > > + * reltuples. > > + */ > > + if (classForm->relkind == RELKIND_PARTITIONED_TABLE) > > + { > > + List *children;

Re: Autovacuum on partitioned table

2020-02-27 Thread Amit Langote
Hosoya-san, Thanks for the new patch. On Wed, Feb 26, 2020 at 11:33 AM yuzuko wrote: > Attach the v5 patch. In this patch, pgstat_report_analyze() always reports 0 > as > msg.m_live_tuples and m_dead_tuples when the relation is partitioned. Some comments: + * PgStat_MsgPartAnalyzeSen

Re: Autovacuum on partitioned table

2020-02-27 Thread Alvaro Herrera
Hello Yuzuko, > + * Report ANALYZE to the stats collector, too. If the table is a > + * partition, report changes_since_analyze of its parent because > + * autovacuum process for partitioned tables needs it. Reset the > + * changes_since_analyze counter only if we analyzed al

Re: Autovacuum on partitioned table

2020-02-27 Thread Masahiko Sawada
On Wed, 26 Feb 2020 at 11:33, yuzuko wrote: > > Hi, > > Thanks for reviewing the patch. > > > > We can make it work correctly but I think perhaps we can skip updating > > > statistics values of partitioned tables other than n_mod_since_analyze > > > as the first step. Because if we support also n_

Re: Autovacuum on partitioned table

2020-02-25 Thread yuzuko
Hi, Thanks for reviewing the patch. > > We can make it work correctly but I think perhaps we can skip updating > > statistics values of partitioned tables other than n_mod_since_analyze > > as the first step. Because if we support also n_live_tup and > > n_dead_tup, user might get confused that o

Re: Autovacuum on partitioned table

2020-02-21 Thread Amit Langote
On Fri, Feb 21, 2020 at 4:47 PM Masahiko Sawada wrote: > Thank you for updating the patch. I tested v4 patch. > > After analyze or autoanalyze on partitioned table n_live_tup and > n_dead_tup are updated. However, TRUNCATE and VACUUM on the > partitioned table don't change these values until invok

Re: Autovacuum on partitioned table

2020-02-20 Thread Masahiko Sawada
On Fri, 21 Feb 2020 at 15:14, yuzuko wrote: > > Hello Amit-san, > > Thanks for your comments. > > > * White-space noise in the diff (space used where tab is expected); > > please check with git diff --check and fix. > Fixed it. > > > * Names changes_tuples, m_changes_tuples should be changed_tuple

Re: Autovacuum on partitioned table

2020-02-20 Thread yuzuko
Hello Amit-san, Thanks for your comments. > * White-space noise in the diff (space used where tab is expected); > please check with git diff --check and fix. Fixed it. > * Names changes_tuples, m_changes_tuples should be changed_tuples and > m_changed_tuples, respectively? Yes, I modified it. >

Re: Autovacuum on partitioned table

2020-02-20 Thread Amit Langote
On Thu, Feb 20, 2020 at 5:32 PM Amit Langote wrote: > On Thu, Feb 20, 2020 at 4:50 PM Amit Langote wrote: > > * I may be missing something, but why doesn't do_autovacuum() fetch a > > partitioned table's entry from pgstat instead of fetching that for > > individual children and adding? That is, w

Re: Autovacuum on partitioned table

2020-02-20 Thread Amit Langote
On Thu, Feb 20, 2020 at 4:50 PM Amit Langote wrote: > * I may be missing something, but why doesn't do_autovacuum() fetch a > partitioned table's entry from pgstat instead of fetching that for > individual children and adding? That is, why do we need to do the > following: > > +/* > +

Re: Autovacuum on partitioned table

2020-02-19 Thread Amit Langote
Hosoya-san, On Thu, Feb 20, 2020 at 3:34 PM yuzuko wrote: > Attach the latest patch based on discussion in this thread. > > > > Yeah that is what I meant. In addition, adding partition's > > > changes_since_analyze to its parent needs to be done recursively as > > > the parent table could also be

Re: Autovacuum on partitioned table

2020-02-19 Thread yuzuko
Hello, I'm sorry for the delay. Attach the latest patch based on discussion in this thread. > > Yeah that is what I meant. In addition, adding partition's > > changes_since_analyze to its parent needs to be done recursively as > > the parent table could also be a partitioned table. > > That's a g

Re: Autovacuum on partitioned table

2020-02-02 Thread Amit Langote
On Sun, Feb 2, 2020 at 12:53 PM Masahiko Sawada wrote: > On Wed, 29 Jan 2020 at 17:56, Amit Langote wrote: > > On Wed, Jan 29, 2020 at 11:29 AM yuzuko wrote: > > > > How are you going to track changes_since_analyze of partitioned table? > > > > It's just an idea but we can accumulate changes_sin

Re: Autovacuum on partitioned table

2020-02-01 Thread Masahiko Sawada
On Wed, 29 Jan 2020 at 17:56, Amit Langote wrote: > > On Wed, Jan 29, 2020 at 11:29 AM yuzuko wrote: > > > Besides the complexity of > > > getting that infrastructure in place, an important question is whether > > > the current system of applying threshold and scale factor to > > > changes_since_

Re: Autovacuum on partitioned table

2020-01-29 Thread Michael Paquier
On Wed, Jan 29, 2020 at 05:56:40PM +0900, Amit Langote wrote: > Yes, we will need to first support those parameters on partitioned > tables. Currently, you get: > > create table p (a int) partition by list (a) with > (autovacuum_analyze_scale_factor=0); > ERROR: unrecognized parameter "autovacuu

Re: Autovacuum on partitioned table

2020-01-29 Thread Amit Langote
On Wed, Jan 29, 2020 at 11:29 AM yuzuko wrote: > > Besides the complexity of > > getting that infrastructure in place, an important question is whether > > the current system of applying threshold and scale factor to > > changes_since_analyze should be used as-is for inheritance parents > > (parti

  1   2   >