pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Why is n_distinct always -1 for range types?
3+ messages / 2 participants
[nested] [flat]

* Why is n_distinct always -1 for range types?
@ 2013-09-19 20:47 Josh Berkus <josh@agliodbs.com>
  2013-09-25 17:29 ` Re: Why is n_distinct always -1 for range types? Josh Berkus <josh@agliodbs.com>
  2013-09-25 17:53 ` Re: Why is n_distinct always -1 for range types? Peter Geoghegan <peter.geoghegan86@gmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Josh Berkus @ 2013-09-19 20:47 UTC (permalink / raw)
  To: pgsql-performance

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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Why is n_distinct always -1 for range types?
  2013-09-19 20:47 Why is n_distinct always -1 for range types? Josh Berkus <josh@agliodbs.com>
@ 2013-09-25 17:29 ` Josh Berkus <josh@agliodbs.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Josh Berkus @ 2013-09-25 17:29 UTC (permalink / raw)
  To: pgsql-performance

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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Why is n_distinct always -1 for range types?
  2013-09-19 20:47 Why is n_distinct always -1 for range types? Josh Berkus <josh@agliodbs.com>
@ 2013-09-25 17:53 ` Peter Geoghegan <peter.geoghegan86@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Peter Geoghegan @ 2013-09-25 17:53 UTC (permalink / raw)
  To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-performance

On Thu, Sep 19, 2013 at 1:47 PM, Josh Berkus <josh@agliodbs.com> 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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-09-25 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-09-19 20:47 Why is n_distinct always -1 for range types? Josh Berkus <josh@agliodbs.com>
2013-09-25 17:29 ` Josh Berkus <josh@agliodbs.com>
2013-09-25 17:53 ` Peter Geoghegan <peter.geoghegan86@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox