Re: planner chooses incremental but not the best one - Mailing list pgsql-hackers

From Andrei Lepikhov
Subject Re: planner chooses incremental but not the best one
Date
Msg-id a2f7d8ef-b002-4633-a58f-496795bc9a97@postgrespro.ru
Whole thread Raw
In response to Re: planner chooses incremental but not the best one  (Tomas Vondra <tomas.vondra@enterprisedb.com>)
Responses Re: planner chooses incremental but not the best one
List pgsql-hackers
On 18/12/2023 19:53, Tomas Vondra wrote:
> On 12/18/23 11:40, Richard Guo wrote:
> The challenge is where to get usable information about correlation
> between columns. I only have a couple very rought ideas of what might
> try. For example, if we have multi-column ndistinct statistics, we might
> look at ndistinct(b,c) and ndistinct(b,c,d) and deduce something from
> 
>      ndistinct(b,c,d) / ndistinct(b,c)
> 
> If we know how many distinct values we have for the predicate column, we
> could then estimate the number of groups. I mean, we know that for the
> restriction "WHERE b = 3" we only have 1 distinct value, so we could
> estimate the number of groups as
> 
>      1 * ndistinct(b,c)
Did you mean here ndistinct(c,d) and the formula:
ndistinct(b,c,d) / ndistinct(c,d) ?

Do you implicitly bear in mind here the necessity of tracking clauses 
that were applied to the data up to the moment of grouping?

-- 
regards,
Andrei Lepikhov
Postgres Professional




pgsql-hackers by date:

Previous
From: "Zhijie Hou (Fujitsu)"
Date:
Subject: RE: Synchronizing slots from primary to standby
Next
From: Sutou Kouhei
Date:
Subject: Re: Make COPY format extendable: Extract COPY TO format implementations