Re: Why DISTINCT ... DESC is slow?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Why DISTINCT ... DESC is slow?
Дата
Msg-id 457E7254.1030500@archonet.com
обсуждение исходный текст
Ответ на Re: Why DISTINCT ... DESC is slow?  (Anton <anton200@gmail.com>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Anton
Дата:
Сообщение: Re: Why DISTINCT ... DESC is slow?
Следующее
От: "surabhi.ahuja"
Дата:
Сообщение: any api in libpq to get the number of connections