Re: extended stats on partitioned tables

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: extended stats on partitioned tables
Date: 2021-11-04 02:20:56
Message-ID: 20211104022056.GQ17618@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 04, 2021 at 12:44:45AM +0100, Tomas Vondra wrote:
> > I probably did this to make the code change small, to avoid indentin the whole
> > block.
>
> But indenting the block is not necessary. It's possible to do something
> like this:
>
> if (!rel->inh)
> return 1.0;
>
> or whatever is the "default" result for that function.

You're right. I did like that, Except in examine_variable, which already does
it with "break".

> > Maybe the for inh<=1 loop should instead be two calls to new functions factored
> > out of get_relation_statistics() and RemoveStatisticsById(), which take "bool
> > inh".

I did like that in a separate patch for now.
And I avoided making a !inh tuple for partitioned tables, since they're never
populated.

> >> And I'm not sure we do the right thing after removing children, for example
> >> (that should drop the inheritance stats, I guess).
> >
> > Do you mean for inheritance only ? Or partitions too ?
> > I think for partitions, the stats should stay.
> > And for inheritence, they can stay, for consistency with partitions, and since
> > it does no harm.
> >
>
> I think the behavior should be the same as for data in pg_statistic,
> i.e. if we keep/remove those, we should do the same thing for extended
> statistics.

This works for column stats the way I proposed for extended stats: child stats
are never removed, neither when the only child is dropped, nor when re-running
ANALYZE (actually, that part is odd).

I can stop sending patches if it makes it hard to reconcile, but I wanted to
put it "on paper" to see/show what the patch series would look like, for v15
and back branches.

--
Justin

Attachment Content-Type Size
v3-0001-Do-not-use-extended-statistics-on-inheritence-tre.patch text/x-diff 6.2 KB
v3-0002-Build-inherited-extended-stats-on-partitioned-tab.patch text/x-diff 6.6 KB
v3-0003-Add-stxdinherit-build-inherited-extended-stats-on.patch text/x-diff 29.2 KB
v3-0004-f-check-inh.patch text/x-diff 7.9 KB
v3-0005-Maybe-better-than-looping-twice.-For-partitioned-.patch text/x-diff 12.3 KB
v3-0005-Maybe-better-way-than-looping-twice.-Change-parti.patch text/x-diff 12.4 KB
v3-0006-Refactor-parent-ACL-check.patch text/x-diff 6.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-11-04 02:39:14 Re: Missing include <openssl/x509.h> in be-secure-openssl.c?
Previous Message Michael Paquier 2021-11-04 02:16:39 Re: Missing include <openssl/x509.h> in be-secure-openssl.c?