From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Anton <anton200(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why DISTINCT ... DESC is slow? |
Date: | 2006-12-12 09:11:48 |
Message-ID: | 457E7254.1030500@archonet.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Anton wrote:
>> SELECT login_id, MAX(collect_time) AS most_recent
>> FROM n_traffic
>> GROUP BY login_id
>> ORDER BY login_id DESC, collect_time DESC
> is not so good:
> =# SELECT login_id, MAX(collect_time) AS most_recent
> -# FROM n_traffic
> -# GROUP BY login_id
> -# ORDER BY login_id DESC, collect_time DESC;
> ERROR: column "n_traffic.collect_time" must appear in the GROUP BY
> clause or be used in an aggregate function
>
> If I correct this error (add collect time to GROUP BY) I'll just get
> full table, sorted. And I tried to not use aggregate functions because
> they make to do full table scan...
Sorry - my typo. The order-by doesn't need "collect_time" of course.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Rikard Pavelic | 2006-12-12 09:30:07 | returning parameters from function |
Previous Message | Anton | 2006-12-12 08:59:16 | Re: Why DISTINCT ... DESC is slow? |