Search Postgresql Archives

Re: Why DISTINCT ... DESC is slow?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux