On Mon, Jul 25, 2005 at 06:11:08PM -0300, Marc G. Fournier wrote:
> Just curious as to whether or not a warning or something should be issued
> in a case like:
> SELECT c.*
> FROM company c, company_summary cs
> WHERE c.id = cs.id
> AND cs.detail = 'test'
> ORDER BY cs.fullname;
> Unless I'm missing something, the ORDER BY clause has no effect, but an
> EXPLAIN shows it does take extra time, obviously ...
Why would it have no effect? If there is a one to many mapping between
fullname and id, and if the rows in c with the same fullname have
different rows in c.*, then it does matter.
For the casual observer, only seeing the output of the table, they would
see a consistent reporting order, but would be unable to derive how the
table rows were sorted. :-)
mark(at)mielke(dot)cc / markm(at)ncf(dot)ca / markm(at)nortel(dot)com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
In response to
pgsql-hackers by date
|Next:||From: Andrew Dunstan||Date: 2005-07-25 23:06:33|
|Subject: Re: Couple of minor buildfarm issues|
|Previous:||From: Marc G. Fournier||Date: 2005-07-25 22:25:28|
|Subject: Re: ORDER BY <field not in return list>|