Re: [GENERAL] Unexpected sort order.

2006-11-27 Thread Jeff Davis
On Mon, 2006-11-27 at 17:05 -0500, Tom Lane wrote: > Jeff Davis <[EMAIL PROTECTED]> 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

Re: [GENERAL] Unexpected sort order.

2006-11-27 Thread Tom Lane
Ron Mayer <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> 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. > Would it be a smaller waste of cycles and s

Re: [GENERAL] Unexpected sort order.

2006-11-27 Thread Tom Lane
I wrote: > 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. > ... What's the use-case for sorting by a volatile > expression in the first place? It may be

Re: [GENERAL] Unexpected sort order.

2006-11-27 Thread Ron Mayer
Tom Lane wrote: > Jeff Davis <[EMAIL PROTECTED]> writes: >> On Mon, 2006-11-27 at 12:44 -0800, Ron Mayer wrote: >>> li=# select * from (select (random()*10)::int as a, (random()*10)::int as b >>> from generate_series(1,10) order by a) as x order by b; > >> It looks like a planner bug. > > It loo

Re: [GENERAL] Unexpected sort order (suspected bug)

2006-11-27 Thread Ron Mayer
Jeff Davis wrote: > 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"? >> >> I would have thought since "order by b" is in the outer sql statement it >> would have >> been the one the final result gets or

Re: [GENERAL] Unexpected sort order.

2006-11-27 Thread Tom Lane
Jeff Davis <[EMAIL PROTECTED]> 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) or

Re: [GENERAL] Unexpected sort order.

2006-11-27 Thread Jeff Davis
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"? > > I would have thought since "order by b" is in the outer sql statement it > would have > been the one the final result gets ordered by. > > li=# selec

[GENERAL] Unexpected sort order.

2006-11-27 Thread Ron Mayer
Shouldn't the results of this query shown here been sorted by "b" rather than by "a"? I would have thought since "order by b" is in the outer sql statement it would have been the one the final result gets ordered by. li=# select * from (select (random()*10)::int as a, (random()*10)::int as b f