Re: Multidimensional Histograms - Mailing list pgsql-hackers

From Andrei Lepikhov
Subject Re: Multidimensional Histograms
Date
Msg-id 2ba586f7-ae89-4255-bb6e-37af0808b413@postgrespro.ru
Whole thread Raw
In response to Re: Multidimensional Histograms  (Alexander Cheshev <alex.cheshev@gmail.com>)
List pgsql-hackers
On 8/1/2024 16:21, Alexander Cheshev wrote:
> Hi Andrei,
> 
>> Maybe my wording needed to be more precise. I didn't implement
>> multidimensional histograms before, so I don't know how expensive they
>> are. I meant that for dependency statistics over about six columns, we
>> have a lot of combinations to compute.
> 
> Equi-Depth Histogram in a 6 dimensional case requires 6 times more
> iterations. Postgres already uses Equi-Depth Histogram. Even if you
> increase the number of buckets from 100 to 1000 then there will be no
> overhead as the time complexity of Equi-Depth Histogram has no
> dependence on the number of buckets. So, no overhead at all!

Maybe. For three columns, we have 9 combinations (passes) for building 
dependency statistics and 4 combinations for ndistincts; for six 
columns, we have 186 and 57 combinations correspondingly.
Even remembering that dependency is just one number for one combination, 
building the dependency statistics is still massive work. So, in the 
multicolumn case, having something like a histogram may be more effective.

-- 
regards,
Andrei Lepikhov
Postgres Professional




pgsql-hackers by date:

Previous
From: "Andrey M. Borodin"
Date:
Subject: Re: [PATCH] Add sortsupport for range types and btree_gist
Next
From: Andrei Lepikhov
Date:
Subject: Re: Custom explain options