<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>