* Alvaro Herrera:
> Miroslav ?ulc wrote:
>> The GROUP BY is really fast :-)
>
> Doh! How does it do it?
It uses a hash table and can therefore discard duplicate rows more
quickly (essentially linear time in the number of rows if the number
of different rows is bounded).
Greg Stark napsal(a):
Actually you could try the equivalent query:
SELECT Key FROM MRTPContactValue GROUP BY Key
This may or may not be faster because it can use a hash aggregate plan. I
would expect it to be faster here because there are few distinct keys and the
planner predicts that.
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> Miroslav ?ulc wrote:
> > 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)
> >
Miroslav ?ulc wrote:
> The GROUP BY is really fast :-)
Doh! How does it do it?
--
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
---(end of broadcast)---
TIP 1: if posting
The GROUP BY is really fast :-)
Thank you.
Miroslav Šulc
Tom Lane napsal(a):
> Try
> SELECT Key FROM MRTPContactValue GROUP BY Key
>
> The "select distinct" code is a bit old and crufty, GROUP BY is usually
> smarter.
>
> regards, tom lane
>
begin:vcard
fn;quoted-
=?ISO-8859-2?Q?Miroslav_=A9ulc?= <[EMAIL PROTECTED]> writes:
> 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
It might be a good solution :-)
Thank you for your help.
Miroslav Šulc
Alvaro Herrera napsal(a):
> Miroslav ?ulc wrote:
>
>> 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)
>> MR
Miroslav ?ulc wrote:
> 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 ke
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 th
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 F
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
Here is the
11 matches
Mail list logo