Why is n_distinct always -1 for range types?

Поиск
Список
Период
Сортировка
Искать

Why is n_distinct always -1 for range types?

От:
Josh Berkus <josh@agliodbs.com>
Дата:
Test:

1. create a table with a range type column.
2. insert 1000 identical values into that column.
3. analyze
4. n-distinct will still be listed as -1 (unique) for the column.

Why?

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

Re: Why is n_distinct always -1 for range types?

От:
Josh Berkus <josh@agliodbs.com>
Дата:
On 09/19/2013 01:47 PM, Josh Berkus wrote:
> Test:
> 
> 1. create a table with a range type column.
> 2. insert 1000 identical values into that column.
> 3. analyze
> 4. n-distinct will still be listed as -1 (unique) for the column.
> 
> Why?
> 

Anyone?

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

Re: Why is n_distinct always -1 for range types?

От:
Peter Geoghegan <peter.geoghegan86@gmail.com>
Дата:
On Thu, Sep 19, 2013 at 1:47 PM, Josh Berkus  wrote:
> 4. n-distinct will still be listed as -1 (unique) for the column.
>
> Why?


Because of this:

https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/rangetypes_typanalyze.c#L205

We only collect and use histograms of lower and upper bounds for range
types, and the fraction of empty ranges.

-- 
Regards,
Peter Geoghegan

FAQ