Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aT0ST-0001B4-RK for pgsql-sql@arkaria.postgresql.org; Tue, 09 Feb 2016 05:03:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aT0SS-0000oA-N5 for pgsql-sql@arkaria.postgresql.org; Tue, 09 Feb 2016 05:03:24 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aT0RU-00088v-FZ for pgsql-sql@postgresql.org; Tue, 09 Feb 2016 05:02:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aT0PN-0005Z9-KB for pgsql-sql@postgresql.org; Tue, 09 Feb 2016 05:00:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u19509HP021083; Tue, 9 Feb 2016 00:00:09 -0500 From: Tom Lane To: "Venkatesan, Sekhar" cc: "pgsql-sql@postgresql.org" Subject: Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order. In-reply-to: References: Comments: In-reply-to "Venkatesan, Sekhar" message dated "Tue, 09 Feb 2016 04:29:15 +0000" Date: Tue, 09 Feb 2016 00:00:09 -0500 Message-ID: <21082.1454994009@sss.pgh.pa.us> X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org "Venkatesan, Sekhar" 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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql