From: | Maximilian Tyrtania <maximilian(dot)tyrtania(at)onlinehome(dot)de> |
---|---|
To: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Distinct oddity |
Date: | 2009-05-08 09:28:40 |
Message-ID: | C629C7E8.35E64%maximilian.tyrtania@onlinehome.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
am 07.05.2009 20:54 Uhr schrieb Scott Marlowe unter scott(dot)marlowe(at)gmail(dot)com:
> On Thu, May 7, 2009 at 2:21 AM, Maximilian Tyrtania
> <maximilian(dot)tyrtania(at)onlinehome(dot)de> wrote:
>> Hi there,
>>
>> does this look right?
>>
>> FAKDB=# select count(distinct(f.land)) from firmen f where
>> f.typlist='Redaktion';
>> count
>> -------
>> 1975
>> (1 row)
>>
>> FAKDB=# select count(distinct(f.land||'1')) from firmen f where
>> f.typlist='Redaktion';
>> count
>> -------
>> 4944
>> (1 row)
>
> Yeah, that does seem odd. Could it be something like nulls in your
> data set? just guessing really. If you could make a small test case
> that shows it happening and allows others to reproduce it you're
> likely to get more bites.
It doesn't seem to be related to null values (which wouldn't explain it
anyway) nor to this particular field...
FAKDB=# select count(*) from firmen where bezeichnung is null;
count
-------
0
(1 row)
FAKDB=# select count(distinct(f.bezeichnung)) from firmen f;
count
-------
72698
(1 row)
FAKDB=# select count(distinct(f.bezeichnung||'e')) from firmen f;
count
-------
72892
(1 row)
My attempts at reproducing this with a freshly created table failed, of
course.
FAKDB=# create table concattest(mytext text);
CREATE TABLE
FAKDB=# insert into concattest (mytext)
select(generate_series(1,10000)::text);
INSERT 0 10000
FAKDB=# insert into concattest (mytext)
select(generate_series(1,10000)::text);
INSERT 0 10000
FAKDB=# select count(distinct(mytext)) from concattest;
count
-------
10000
(1 row)
FAKDB=# select count(distinct(mytext||'2')) from concattest;
count
-------
10000
(1 row)
best,
Maximilian Tyrtania
From | Date | Subject | |
---|---|---|---|
Next Message | Jyoti Seth | 2009-05-08 09:31:01 | backup and restore |
Previous Message | Luigi N. Puleio | 2009-05-08 09:05:08 | RAISE NOTICE |