Re: Unexpected sort order.
От | Tom Lane |
---|---|
Тема | Re: Unexpected sort order. |
Дата | |
Msg-id | 24807.1164665127@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Unexpected sort order. (Jeff Davis <pgsql@j-davis.com>) |
Ответы |
Re: Unexpected sort order.
Re: Unexpected sort order. Re: Unexpected sort order. |
Список | pgsql-general |
Jeff Davis <pgsql@j-davis.com> writes: > On Mon, 2006-11-27 at 12:44 -0800, Ron Mayer wrote: >> Shouldn't the results of this query shown here been sorted by "b" rather than by "a"? >> li=# select * from (select (random()*10)::int as a, (random()*10)::int as b from generate_series(1,10) order by a) asx order by b; > It looks like a planner bug. It looks to me like the planner thinks that order by a and order by b are equivalent because the expressions are equal(); hence it discards what it thinks is a redundant second sort step. I suppose we could add a check for whether the sort expression contains volatile functions before believing this, but I'm having a hard time believing that there are any real-world cases where the check wouldn't be a waste of cycles. What's the use-case for sorting by a volatile expression in the first place? regards, tom lane
В списке pgsql-general по дате отправления: