From: | Miroslav Šulc <miroslav(dot)sulc(at)startnet(dot)cz> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: SELECT DISTINCT too slow |
Date: | 2006-06-01 14:49:54 |
Message-ID: | 447EFE92.2070509@startnet.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Well, "key" is not primary key from another table. It is just a column
in pair "key" => "value".
The structure of the table is this:
Id (primary key)
MRTPContactId (id of contact from table MRTPContact)
Key (key from pair key => value)
Value (value from pair key => value)
So I want the get the list of keys used in the table.
Miroslav Šulc
Alvaro Herrera napsal(a):
> Miroslav ?ulc wrote:
>
>> Hello,
>>
>> I have a table with cca 400,000 rows. The table contains column "key" of
>> varchar(20) type containing 10 distinct values. I want to get out what
>> distinct values are present in the column. I use this simple query,
>> which is very slow:
>>
>> SELECT DISTINCT Key FROM MRTPContactValue
>>
>
> You could get the universe of values from the table where this is a
> primary key, and use an IN clause (which apparently is more efficient
> than an EXISTS in some cases, but try that too) to search for values
> that exist in the MRTPContactValue table.
>
> I assume you do have the other table, don't you?
>
>
Attachment | Content-Type | Size |
---|---|---|
miroslav.sulc.vcf | text/x-vcard | 349 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2006-06-01 14:53:28 | Re: SELECT DISTINCT too slow |
Previous Message | Thomas Chille | 2006-06-01 14:21:58 | Re: distinct aggregate with complex type dont see the equality operator [solved] |