Re: ALTER TABLE ... ALTER COLUMN ... SET DISTINCT

From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE ... ALTER COLUMN ... SET DISTINCT
Date: 2009-08-01 11:27:20
Message-ID: 2BF94AAA-BDDD-4144-A375-06D5795156FF@hi-media.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Le 1 août 09 à 06:08, Robert Haas a écrit :
> I'm lost. I think you're getting the new column attdistinct mixed up
> with the existing column stadistinct. attdistinct is always going to
> have whatever value you assign it. stadistinct will get attdistinct
> != 0 ? attdistinct : <result of analyze calculation>.

haha!
Sorry about that, I felt like I had to run against time and once again
I lost.

dim=# alter table foo alter column x set distinct 0.25;
ALTER TABLE
dim=# select stadistinct from pg_statistic where starelid =
'foo'::regclass;
-[ RECORD 1 ]-----
stadistinct | 0.25

dim=# alter table foo alter column x set distinct 0;
ALTER TABLE
dim=# analyze verbose foo;
INFO: analyzing "public.foo"
INFO: "foo": scanned 4 of 4 pages, containing 1000 live rows and 0
dead rows; 1000 rows in sample, 1000 estimated total rows
ANALYZE
dim=# select stadistinct from pg_statistic where starelid =
'foo'::regclass;
stadistinct
-------------
-0.652
(1 row)

I'm back on track, it seems. Time to further test this, but code
review is ok for me (except for the strange new error already
mentioned), doc is ok too, and basic behaviour is sane. I just checked
pg_dump dim|psql foo and new database (foo) has same explicit distinct
settings than origin, both for pg_attribute and pg_statistic.

Unless you want me to test for impact on planner choices (even if we
already know it has impact on pg_statistic), I'd say it's ready for
commiter.

--
dim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2009-08-01 13:52:30 Re: SE-PostgreSQL Specifications
Previous Message PFC 2009-08-01 07:37:11 Re: More thoughts on sorting