Search Postgresql Archives

Re: Weird query sort

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

 



"Jeffrey Melloy" <jmelloy@xxxxxxxxx> writes:
> It seems like I should be able to order by quer_time desc and then
> query_time asc. Am I missing something?

You'd have to do it *after* the join and GROUP BY if you want it to
control the input to the aggregate reliably.  Either of those operations
will feel free to output rows in whatever order suits its convenience.
Ordering in the sub-select is useful in connection with making sure its
LIMIT produces the tuples you want, but it isn't going to be preserved
through the join and GROUP BY.

Also, I think what you really need here is to have the intermediate
query "ORDER BY queries.query_id, query_time"; otherwise you risk
having the GROUP BY do a sort by query_id, which'll destroy the desired
ordering on query_time within query_id groups.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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