Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order. - Mailing list pgsql-sql

From Venkatesan, Sekhar
Subject Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.
Date
Msg-id F84DE43FDACD4C45AA84E2DA016FAE2F1C65BEC8@MX105CL01.corp.emc.com
Whole thread Raw
In response to Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.  (Rob Sargent <robjsargent@gmail.com>)
Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-sql
<div class="WordSection1"><p class="MsoPlainText">Hi Tom,<p class="MsoPlainText"> <p class="MsoPlainText">You can
disregardthe "TOP 10" modifier. That was added by me to bring down the huge number of results being returned.<p
class="MsoPlainText">Evenwithout the TOP modifier, SQL server is returning rows in sorted order (sorting columns based
onthe r_object_id (1<sup>st</sup>) column I think) but PostgreSQL doesn’t.<p class="MsoPlainText">Is this anything to
dowith indexes?<p class="MsoPlainText">So from what I understand, you say in postgres, if the sort order is not
specified,postgres returns results in any order. Am I right?<p class="MsoPlainText"> <p
class="MsoPlainText">-----OriginalMessage-----<br /> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] <br /> Sent: Tuesday,
February09, 2016 10:30 AM<br /> To: Venkatesan, Sekhar<br /> Cc: pgsql-sql@postgresql.org<br /> Subject: Re: [SQL]
Questionon PostgreSQL DB behavior w.r.t JOIN and sort order.<p class="MsoPlainText"> <p
class="MsoPlainText">"Venkatesan,Sekhar" <<a href="mailto:sekhar.venkatesan@emc.com"><span
style="color:windowtext;text-decoration:none">sekhar.venkatesan@emc.com</span></a>>writes:<p
class="MsoPlainText">>I am seeing this behavior change in postgreSQL DB when compared to SQL Server DB when JOIN is
performed.The sort order is not retained when JOIN is performed in PostgreSQL DB.<p class="MsoPlainText"> <p
class="MsoPlainText">Whatsort order?  You did not specify any ORDER BY clause, so the DBMS is entitled to return rows
inany order it feels like.<p class="MsoPlainText"> <p class="MsoPlainText">I do not know anything about this "top 10"
modifieryou've got in the SQL Server version, but I suspect it's implying a sort order.  In Postgres, if you want a
specificrow ordering, you need to say ORDER BY.<p class="MsoPlainText"> <p
class="MsoPlainText">                                               regards, tom lane</div> 

pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.
Next
From: Rob Sargent
Date:
Subject: Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order.