From: | "Venkatesan, Sekhar" <sekhar(dot)venkatesan(at)emc(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order. |
Date: | 2016-02-09 05:21:45 |
Message-ID: | F84DE43FDACD4C45AA84E2DA016FAE2F1C65BEC8@MX105CL01.corp.emc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi Tom,
You can disregard the "TOP 10" modifier. That was added by me to bring down the huge number of results being returned.
Even without the TOP modifier, SQL server is returning rows in sorted order (sorting columns based on the r_object_id (1st) column I think) but PostgreSQL doesn't.
Is this anything to do with indexes?
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?
-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Tuesday, February 09, 2016 10:30 AM
To: Venkatesan, Sekhar
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Question on PostgreSQL DB behavior w.r.t JOIN and sort order.
"Venkatesan, Sekhar" <sekhar(dot)venkatesan(at)emc(dot)com<mailto:sekhar(dot)venkatesan(at)emc(dot)com>> writes:
> 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.
What sort order? You did not specify any ORDER BY clause, so the DBMS is entitled to return rows in any order it feels like.
I do not know anything about this "top 10" modifier you've got in the SQL Server version, but I suspect it's implying a sort order. In Postgres, if you want a specific row ordering, you need to say ORDER BY.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Sargent | 2016-02-09 05:33:43 | Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order. |
Previous Message | Tom Lane | 2016-02-09 05:00:09 | Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order. |