Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aT1MD-0003Yt-UA for pgsql-sql@arkaria.postgresql.org; Tue, 09 Feb 2016 06:01:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aT1MD-0008GP-H2 for pgsql-sql@arkaria.postgresql.org; Tue, 09 Feb 2016 06:01:01 +0000 Received: from makus.postgresql.org ([174.143.35.229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aT1MB-0008EL-E2 for pgsql-sql@postgresql.org; Tue, 09 Feb 2016 06:00:59 +0000 Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aT1M9-00089R-2Q for pgsql-sql@postgresql.org; Tue, 09 Feb 2016 06:00:58 +0000 Received: by mail-io0-x234.google.com with SMTP id d63so7918791ioj.2 for ; Mon, 08 Feb 2016 22:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2HRCXSztkZVA0SdFzez2etSMK/eBDvlEzDwsyHjS9dE=; b=Tq2ulXwv6kMOrqDCJwhDh/lMMiEkmeikjtzmlH4DTOnQNHDCvyG4f0GqXWfxVju265 IHkbbpCDKUTcJHtVOshQTuOE42K4UKGVExpKaUo7D6UHZrJTcB4CgcoOG6fVF4MXK/ii 1HnvEtUsr2cyS4/9M8FTVY/holC5PVFgNTPJcfzUeFVYFRdNskjDqDbH9bvDBpUyRYYQ QcAbKpPh5eF2S74adXED66TQH2PI+MIGN+uR9iSnxitXZnJHcOxjd6RpnT7cSmu/gcDS wCEonSK8JBUcOqNnW2VmBPA0vNt6rYvlvG/1oa5puIYMuK7m7iWnp6eYyesyDcU248n/ 2Q8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=2HRCXSztkZVA0SdFzez2etSMK/eBDvlEzDwsyHjS9dE=; b=cpFanLb4iw/K1J3+6wIG0h+xPNumzgZ7tm6aRB8t9Q7l4t9s7IPVnr7yeIKGE/2LPn fcZfEvHlKEMi2s9MhcxFwkwPKq6Px/YQHeufa3H/RY/qx+fLnEpSrPGsmf+6v9bioxkR iw61Wp7aP1oUG10/itKP3QQ0uzOq67YmC5oKRgzQOKEZd3x6cDdF/yijL94Fherf+2li IQglENvgmOA3+HAP3og9zbW6NRzsG2lePwm7sA8kcAmlhPtIp7N1JO9x/Mj7IGRuJJqY fM/TlLrOCgre8OU7EmK/gqBd2J3Wv8iWWE83Xp02hhzx2048BwuOfW8YiSX3itmFgl56 dIEg== X-Gm-Message-State: AG10YOR+b8NEWG1ypGed5WbflPfQfN7yH5F1tzKS9O9JiLJIt/Welh1rP0gtcKUVe2B9e6/Xg1KCBwlguLd01Q== MIME-Version: 1.0 X-Received: by 10.107.129.215 with SMTP id l84mr12148611ioi.47.1454997655979; Mon, 08 Feb 2016 22:00:55 -0800 (PST) Received: by 10.36.153.196 with HTTP; Mon, 8 Feb 2016 22:00:55 -0800 (PST) In-Reply-To: References: <21082.1454994009@sss.pgh.pa.us> Date: Mon, 8 Feb 2016 23:00:55 -0700 Message-ID: Subject: Re: Question on PostgreSQL DB behavior w.r.t JOIN and sort order. From: "David G. Johnston" To: "Venkatesan, Sekhar" Cc: Tom Lane , "pgsql-sql@postgresql.org" Content-Type: multipart/alternative; boundary=001a113ec6ac6f0ad7052b500a96 X-Pg-Spam-Score: -2.7 (--) 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 --001a113ec6ac6f0ad7052b500a96 Content-Type: text/plain; charset=UTF-8 On Monday, February 8, 2016, Venkatesan, Sekhar wrote: > Yes. is there an option/configuration to tell the postgres > optimizer/planner to generate plans to include the sort order instead of > speed? > No. The planner chooses based upon least cost of the exact query given to it. If that query does not have order by the system will not guarantee any specific output order. David J. --001a113ec6ac6f0ad7052b500a96 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, February 8, 2016, Venkatesan, Sekhar <sekhar.venkatesan@emc.com> wrote:

Yes. is there an option/c= onfiguration to tell the postgres optimizer/planner to generate plans to in= clude the sort order instead of speed?=C2=A0

No.=C2=A0 The=C2=A0planner chooses based upon least cost of the e= xact query given to it.=C2=A0 If that query does not have order by the syst= em=C2=A0will not guarantee any specific output order.

<= div>David J. --001a113ec6ac6f0ad7052b500a96--